OSX: 尽管使用 crontab -e 更改设置,但 Crontab 不会执行 sh 脚本
OSX: Crontab will not execute sh script despite using crontab -e to change settings
所以我试图在每天下午 5 点执行一个名为 test.sh 的 shell 文件。 test.sh 文件位于我的桌面上。使用 crontab -e 后,这是我的 crontab 文件的样子:
0 17 * * * * root sh /Users/theuser/Desktop/test
一切都由制表符分隔。因此 0 与 17 之间用制表符分隔,第一个星号与 17 之间用制表符分隔,等等。我的 shell 不是 运行 的原因是语法错误吗?是别的东西吗?提前致谢。
还有一件事:当我第一次执行 crontab -e 时,文件是空的。那是正常的吗?
编写脚本的第一行
#!/bin/bash
在您的终端中键入以下内容以使您的脚本可执行:
chmod +x /Users/SomeUser/Desktop/theScript
让你的crontab
像这样每分钟测试一次
* * * * * /Users/SomeUser/Desktop/theScript
或
0 17 * * * /Users/SomeUser/Desktop/theScript
所以我试图在每天下午 5 点执行一个名为 test.sh 的 shell 文件。 test.sh 文件位于我的桌面上。使用 crontab -e 后,这是我的 crontab 文件的样子:
0 17 * * * * root sh /Users/theuser/Desktop/test
一切都由制表符分隔。因此 0 与 17 之间用制表符分隔,第一个星号与 17 之间用制表符分隔,等等。我的 shell 不是 运行 的原因是语法错误吗?是别的东西吗?提前致谢。
还有一件事:当我第一次执行 crontab -e 时,文件是空的。那是正常的吗?
编写脚本的第一行
#!/bin/bash
在您的终端中键入以下内容以使您的脚本可执行:
chmod +x /Users/SomeUser/Desktop/theScript
让你的crontab
像这样每分钟测试一次
* * * * * /Users/SomeUser/Desktop/theScript
或
0 17 * * * /Users/SomeUser/Desktop/theScript