Search code examples
ruby-on-railscronrbenvwhenever

crontask generate by Whenever doesn't run


I have this cronfile :

# Begin Whenever generated tasks for: mtaville_staging

* * * * * cd /home/mtaville/mtaville_staging/releases/20141202140931 && RAILS_ENV=staging bundle exec rake cinemas:import --silent

# End Whenever generated tasks for: mtaville_staging

but it doesn't run the task.

When I had this :

* * * * * cd /home/mtaville/ && touch "echo.txt"

The file "echot.txt" is created... But not my task !

EDIT

nohup: les entrées sont ignorées
nohup: impossible d'exécuter la commande «cinemas:import»: Aucun fichier ou dossier de ce type

EDIT FINAL

Here is my crontask :

* * * * * /bin/bash -c 'export PATH="$HOME/.rbenv/bin:$PATH" ; eval "$(rbenv init -)"; cd /home/mtaville/mtaville_staging/current ; RAILS_ENV=staging bundle exec rake cinemas:import > /tmp/log.txt 2>&1'

Solution

  • try run the task not silently but with output-forwarding to a file:

    RAILS_ENV=staging bundle exec nohup cinemas:import >/tmp/log.txt 2>&1
    

    so for the has special wrappers, which should be run to setup proper environment, like follows:

    * * * * * cd folder; RAILS_ENV=staging /usr/local/rvm/wrappers/ruby-2.1.1@projectX/bundle exec nohup cinemas:import >/tmp/log.txt 2>&1
    

    if you are using the , the script runner will be seen as follows:

    * * * * * /bin/bash -c '. $HOME/.rbenv/loader.sh; cd folder ; RAILS_ENV=staging bundle exec cinemas:import >/tmp/log.txt 2>&1'