Search code examples
phpubuntucron

How to add sleep setting to cron job


Bellow is my cron command.I want to add the sleep command there.

This is what i tried so far.is that CORRECT ?

* * * * *  root sleep 5 && /home/samitha/bash.sh >> /home/samitha/log/cron.log 2>&1

enter image description here


Solution

  • That is absolutely correct. You can also use ; instead of &&, but in this case it doesn't matter because sleep returns 0 always.

    Update

    This format here is for /etc/crontab.

    If you use users' crontabs (edit them using crontab -e, as on the screenshot), you must omit username from the line:

    * * * * *  sleep 5 && /home/samitha/bash.sh >> /home/samitha/log/cron.log 2>&1