Crontab - simple echo not running

好久不见. 提交于 2019-12-04 16:19:38

问题


I've got such situation: I want to schedule a job with crontab on a linux server. I'm not super-user, so I'm editing (with crontab -l, editor vim) only my crontab file. For testing, I put there:

* * * * * echo asdf

And the job is not running. Is the restart of the server needed? Or maybe some administrator move?


回答1:


May be it is, cron jobs will run in their own shell. So you can't expect to see asdf on your console.

What you should try is

* * * * * echo asdf > somefile_in_your_home_directory_with_complete_path.log

Next check the file by doing a tail:

tail -f somefile_in_your_home_directory_with_complete_path.log

And if it's not, check if the cron daemon itself is running or is down:

# pgrep crond

OR

# service crond status



回答2:


For me * * * * * /bin/echo text > file is not working...I don't know why, previleges and everything is set. (This command is running normaly when I execute it as the particular root user, just to clarify this.) This can be solved by injecting the path PATH=$PATH:/bin in my example.

Instead * * * * * echo text > file is working fine, probably path issue.

Hope I helped



来源:https://stackoverflow.com/questions/28856326/crontab-simple-echo-not-running

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!