且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Linux cronjob不工作(执行脚本)

更新时间:2023-12-04 18:37:46

p>一开始,你不需要 / 1 ,如果你想每一分钟。只需将分钟字段设置为 * 即可。

For a start, you don't need the /1 if you want it done every minute. Just setting the minute field to * will do.

接下来, (#!行如果存在):

Next, you should place, as the first lines in your test script (though after the #! line if it's there):

env >/tmp/test.sh.dummy
set >>/tmp/test.sh.dummy

并查看该文件是否显示。

and see if that file shows up.

这将告诉你脚本是否正在运行。

That will tell you if the script is running or not.

如果不是正在运行,请检查以确保 cron 本身正在运行:/ p>

If it's not running, check to make sure cron itself is running:

pax> ps -ef | grep cron | grep -v grep
root      1048     1  0 08:45 ?        00:00:00 cron

(我的)。

如果运行,最可能的问题是 cron 运行您的作业的环境不在环境附近壳给你。检查输出到您的 /tmp/test.sh.dummy 文件和您执行 env时您的shell给出的内容之间的差异;设置

If it is running, the most likely problem is that the environment under which cron runs your jobs is nowhere near the environment your shell gives you. Examine the differences between what was output to your /tmp/test.sh.dummy file and what your shell gives your when you execute env ; set.