Add and Replace Jobs in Crontab

22 views Asked by At

EDIT: This should be done in a script, not opening or editing via crontab -e

I have a list of cron jobs that already exists, below are some of them

*/30 * * * * /path/to/script.sh
0 12 * * * /path/to/script_2.sh
* * * * /path/to/script_3.sh

Scenario:

  1. script_2.sh is not found on some of the servers.
  2. Need to add >/dev/null 2>&1 to all of this script

How can I do in Linux script to search for script_2.sh if that is already present in the crontab? If it is present in the crontab, >/dev/null 2>&1 should be appended. If it doesn't exist, it should be added to the jobs.

0

There are 0 answers