Ubuntu 10.04 LTS Cron not working

I am trying to use cronjob to run a ruby โ€‹โ€‹script (using the 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 test "echo" script "was added as a test, but it does not seem to be running. I am currently using Ubuntu 10.04 LTS .

Am I spelling cronjob wrong?

+3
source share
3 answers

The crontab file is not a shell script. Therefore, you do not need #!/bin/bashto start the file. Plus, the places 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'

, , crontab -e administrator crontab.

+2

, ( . 'script test 'to what? , , cron.

+1

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

0
source

Source: https://habr.com/ru/post/1786959/


All Articles