开发者

Ubuntu 10.04 LTS Cron jobs not working

I'm trying to use a cronjob to run a开发者_StackOverflow社区 ruby script (Using Rails3 runner) with the following Cronjobs:

    #!/bin/bash
    0-59 * * * * echo 'script test'

    # Begin Whenever generated tasks for: test1
    * * * * * /bin/bash -l -c '/home/administrator/test1/script/rails runner /home/administrator/test1/app/create_flag.rb >> /home/administrator/test1/test.log 2>&1'

# End Whenever generated tasks for: test1

test1 is the name of the Rails3 project folder.

the "echo 'script test'" was added as a test, but neither seems to be executing. I'm currently using Ubuntu 10.04 LTS.

Have I written the cronjob incorrectly?


Crontab file is not a shell script. So you don't need #!/bin/bash at the beginning of the file. Plus, spaces there are suspicious. Try something like this:

SHELL=/bin/bash
MAILTO=administrator@localhost
BASH_ENV=/home/administrator/.bash_profile

* * * * * /home/administrator/test1/script/rails runner /home/administrator/test1/app/create_flag.rb >> /home/administrator/test1/test.log 2>&1'

Plus, make sure you call crontab -e as administrator to edit the crontab file.


You need to specify the user which runs the commands (you can see the format here. Also the echo will output 'script test' to what? If you want a test try doing a touch on a file, so you can physically see the action of the cron job.


Cron does not use your user environment, so it will not have the same path set that you have. This means that you should use absolute paths for commands.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜