简体   繁体   English

Cron作业未在Linux上运行

[英]Cron job is not running on Linux

At first, this is not exactly a programming question and more specific to Linux. 刚开始,这并不是一个编程问题,而是更特定于Linux的。 I hope that it can be answered here though. 我希望可以在这里回答。

I have created a cron job which will execute a shell script every 2 minutes on my machine. 我创建了一个cron作业,它将在我的计算机上每2分钟执行一次Shell脚本。 However, the cronjob is not executing. 但是,cronjob没有执行。

output of crontab -e command crontab -e命令的输出

2 * * * * /home/yuri/connector.sh >> /home/yuri/test.txt 2>&1

I have the cron daemon running: 我正在运行cron守护程序:

ps aux | grep cron

root       944  0.0  0.0  19120   932 ?        Ss   08:25   0:02 cron
1000     19619  0.0  0.0  13600   880 pts/2    S+   21:50   0:00 grep --color=auto cron

The connector.sh shell script runs properly when I execute it manually, however when run through the cron job created above, it does not work. 当我手动执行connector.sh shell脚本时,它会正常运行,但是通过上面创建的cron作业运行时,它将无法正常工作。

I have redirected the output to a text file to know if something is going wrong while executing the cron job, but no such text file is created. 我已将输出重定向到文本文件,以了解执行cron作业时是否出了问题,但未创建此类文本文件。

Your cron job isn't set to run every two minutes, it's set to run on the second minute of every hour. 您的Cron作业未设置为每两分钟运行一次,而是设置为每小时的第二分钟运行。 You might change it as follows: 您可以按以下方式更改它:

*/2 * * * * /home/yuri/connector.sh >> /home/yuri/test.txt 2>&1

Running every 2 minutes should be given as 每2分钟应运行为

*/2 * * * * /home/yuri/connector.sh >> /home/yuri/test.txt 2>&1. 

Does this work ? 这行得通吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM