I am trying to make a cron job that stops at 12am today(friday) then start again Monday at 7am, what would the script for this look like, I am new to cron jobs.
-
What have you tried?– harrymcCommented Jul 31, 2020 at 18:55
-
stackoverflow.com/questions/4445088/…– MrPigbotCommented Jul 31, 2020 at 19:00
-
This post isn't really a tutorial. There are heaps of better documents to be found. Keep on searching.– harrymcCommented Jul 31, 2020 at 19:07
1 Answer
* * * * * /bin/timeout -s 2 10 /path/to/your/script.sh
Above kills after 10 minutes.
"12am today (Friday) then start again on Monday at 7am" - This looks more like a SERVICE than a cron job. However it is possible to assign a PID to this long cron job and add another cron job to kill this PID of the first.
The * * * * *
from left to right:
Minute (Numeric) | Hour (Numeric) | Day of Month (Numeric) | Month (Numeric) | Day of the Week (0=Sunday, 1=Monday..)
Month and Day in some crontabs also accepst strings like Dec, Mon etc.