Mono 可执行文件不会 运行 来自 Mac 上的 crontab
Mono executable file will not run from crontab on Mac
我试图在每天的特定时间自动将单声道可执行文件 运行 获取,但是它不会从 crontab 运行。
使用 crontab -e 我设置了以下计划任务:
10 15 * * * (cd ~/Documents/automation && bash auto_run.sh)
在 auto_run.sh 文件中,我有以下内容:
#!/bin/bash
echo “`date “+%Y-%m-%d %H:%M:%S”` : auto run starting >> auto_run_logging.txt
mono /Users/admin/Projects/auto_task/auto_task/bin/Debug/auto_task.exe
echo “`date “+%Y-%m-%d %H:%M:%S”` : auto run ending >> auto_run_logging.txt
我已对文件使用 chmod +x
以确保它们执行。
在预定时间,可以在文本文件中看到 date/time 消息,但单声道可执行文件不会 运行。 运行 直接从终端 bash auto_run.sh
获取的文件完美无缺。
如有任何帮助,我们将不胜感激。我正在使用 macOS Mojave
发生这种情况是因为 mono
无法从 cron 内部找到它应该 运行 的路径。
您可以将路径放入 .bash_profile
并在 运行 启动 cron 时获取它。或 运行 which mono
并提及脚本中的路径 运行 宁 mono
命令。
命令:
which mono
# 它会给你 mono
所在的路径。
脚本为:
#!/bin/bash
echo “`date “+%Y-%m-%d %H:%M:%S”` : auto run starting >> auto_run_logging.txt
/path/to/mono/mono /Users/admin/Projects/auto_task/auto_task/bin/Debug/auto_task.exe
echo “`date “+%Y-%m-%d %H:%M:%S”` : auto run ending >> auto_run_logging.txt
另一种方法是,将 mono
路径放入 .bash_profile
和 运行 cron,如下所示:
10 15 * * * . ~/.bash_profile; (cd ~/Documents/automation && bash auto_run.sh)
我试图在每天的特定时间自动将单声道可执行文件 运行 获取,但是它不会从 crontab 运行。
使用 crontab -e 我设置了以下计划任务:
10 15 * * * (cd ~/Documents/automation && bash auto_run.sh)
在 auto_run.sh 文件中,我有以下内容:
#!/bin/bash
echo “`date “+%Y-%m-%d %H:%M:%S”` : auto run starting >> auto_run_logging.txt
mono /Users/admin/Projects/auto_task/auto_task/bin/Debug/auto_task.exe
echo “`date “+%Y-%m-%d %H:%M:%S”` : auto run ending >> auto_run_logging.txt
我已对文件使用 chmod +x
以确保它们执行。
在预定时间,可以在文本文件中看到 date/time 消息,但单声道可执行文件不会 运行。 运行 直接从终端 bash auto_run.sh
获取的文件完美无缺。
如有任何帮助,我们将不胜感激。我正在使用 macOS Mojave
发生这种情况是因为 mono
无法从 cron 内部找到它应该 运行 的路径。
您可以将路径放入 .bash_profile
并在 运行 启动 cron 时获取它。或 运行 which mono
并提及脚本中的路径 运行 宁 mono
命令。
命令:
which mono
# 它会给你 mono
所在的路径。
脚本为:
#!/bin/bash
echo “`date “+%Y-%m-%d %H:%M:%S”` : auto run starting >> auto_run_logging.txt
/path/to/mono/mono /Users/admin/Projects/auto_task/auto_task/bin/Debug/auto_task.exe
echo “`date “+%Y-%m-%d %H:%M:%S”` : auto run ending >> auto_run_logging.txt
另一种方法是,将 mono
路径放入 .bash_profile
和 运行 cron,如下所示:
10 15 * * * . ~/.bash_profile; (cd ~/Documents/automation && bash auto_run.sh)