【问题标题】:calling dotnet from .sh file through cron is not working通过 cron 从 .sh 文件调用 dotnet 不起作用
【发布时间】:2018-10-28 00:47:50
【问题描述】:

我有一个运行 dotnet 应用程序“dotnet app.name.dll”的脚本 file.sh,当我从终端“./file.sh”调用它时它工作正常。 我使用“crontab -e”制作了一个 cron,每天运行这个脚本,它调用脚本“file.sh”,但它给了我错误:/home/ec2-user/file.sh: line 3: dotnet: command没找到

日志文件:

X-Cron-Env: <XDG_SESSION_ID=423>
X-Cron-Env: <XDG_RUNTIME_DIR=/run/user/1000>
X-Cron-Env: <LANG=en_US.UTF-8>
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/home/ec2-user>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=ec2-user>
X-Cron-Env: <USER=ec2-user>
/home/ec2-user/file.sh: line 3: dotnet: command not found

dotnet 在终端中运行良好,甚至在我直接调用 file.sh 时也可以正常工作

【问题讨论】:

  • 您可以尝试在脚本中给出 dotnet 的完整路径吗? /full/path/to/dotnet
  • 有命令给我点网路径吗?
  • 试试:which dotnet
  • dotnet 路径是:/usr/local/bin/dotnet
  • 我的 cron 是:#!/usr/bin/env bash cd /home/ec2-user/Folder/dotnet app.name.dll

标签: .net linux amazon-ec2 cron sh


【解决方案1】:

尝试在脚本中给出dotnet 的完整路径? /full/path/to/dotnet

根据您对我的问题的回答:

/usr/local/bin/dotnet

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-10-24
    • 2012-07-24
    • 2021-12-10
    • 1970-01-01
    • 2016-06-11
    • 2017-08-05
    • 2014-10-12
    • 1970-01-01
    相关资源
    最近更新 更多