If you create your cron jobs sometimes you would need to test them just to be sure they work properly. So you need to execute them one by one regardless of their schedule.
The magic of command line makes it easy for us to write a command and do it. So here it is:
crontab -l | grep -v '^#' | cut -f 6- -d ' ' | while read CMD; do eval $CMD; done
How does it work…
I’ll explain all parts of this command one by one.
- This part will list all cron jobs we have defined.
- This part will remove comment lines (all lines beginning with ‘#’).
1grep -v '^#'
- This part will remove time/date settings. It will cut every string from start to the fifth position. e.g. for the command bellow it’ll remove “00 09-18 * * *“00 09-18 * * * /home/john/bin/check-db
1cut -f 6- -d ' '
- This part will execute all commands (one by one) we have defined in our cron list.
1while read CMD; do eval $CMD; done