我的 cron 没有运行,/var/mail/ 中没有显示任何内容或在 /var/log/syslog 中

我的 cron 没有运行,/var/mail/ 中没有显示任何内容或在 /var/log/syslog 中
kenneth@ballotreport:~$ crontab -l
# Edit this file to introduce tasks to be run by cron.
# 
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
# 
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').# 
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
# 
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
# 
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
# 
# For more information see the manual pages of crontab(5) and cron(8)
# 
# m h  dom mon dow   command

* * * * * /usr/bin/pgrep -f /var/www/whatapp/send_messages_out_cron.sh > /dev/null 2> /dev/null || /var/www/whatapp/send_messages_out_cron.sh >> /tmp/testcronlog.log

该文件/tmp/testcronlog.log永远不会被创建。该命令在终端上运行时运行完美。我不知道问题出在哪里

答案1

我找不到文档来确认或否认这一点,但请记住 cron 条目不是 shell 脚本。我假设逻辑或是不允许的。要么在脚本中添加逻辑以防止多个实例(我相信这就是您使用 pgrep 的原因),要么创建一个要在 cron 中调度的包装器脚本。

相关内容