I am trying to add a script to cron jobs to be played daily.

I tried multiple things but no one seems to work.

First I tried to add a script in cron.daily: It s not triggered.


cd ~/foo/
/usr/bin/mvn exec:java -Dexec.mainClass="bar.foo.Main" > ~/foo.log

Then I tried to add a line in crontab using vi crontab same thing

17 *    * * *   root    cd ~/foo/ && /usr/bin/mvn exec:java -Dexec.mainClass="bar.foo.Main" > ~/foo.log

Then I tried to use crontab -e and add the same line than before : nothing.

It s the first time I tried to launch a periodic script... Is there something to restart?

PS : Why vi crontab and crontab -e don't display the same thing?

  • 1
    for your script, did you make it executable chmod +x yourscript.sh Feb 27 '15 at 11:51
  • nope he wasn't! I am going to try it like that. Does it have to be .sh? Other scripts in cron.daily don't have extension
    – Labe
    Feb 27 '15 at 12:04
  • No it doesn't, that was just an example as I don't know your filename.. Feb 27 '15 at 12:07
  • OK. Is there some log file I could have seen that it was a right problem?
    – Labe
    Feb 27 '15 at 12:11
  • I believe it's /var/log/syslog Feb 27 '15 at 12:18

Make sure your script is executable

chmod +x yourscript.sh

Not the answer you're looking for? Browse other questions tagged or ask your own question.