i was asked to write shell script to perform the following task:
update cronentry from
\*/15 * * * * /bin/sh /opt/myscript/myscript.sh > /tmp/myscript.check.out
to
\*/30 2,4,6 * * * /bin/sh /opt/myscript/myscript2.sh > /tmp/myscript2.check.out
before edit take a backup of the cronentry
i have tried the following script and need to check if it will work or does require any modification - please help!!
Shell Script to update cronentry(backup before edit)
#!/bin/sh
crontab -l > my_crontab.backup
crontab -l | grep -v "*/30 2,4,6 * * * /bin/sh /opt/myscript/myscript2.sh > /tmp/myscript2.check.out" >*/15 * * * * /bin/sh /opt/myscript/myscript.sh > /tmp/myscript.check.out
echo "*/30 2,4,6 * * * /bin/sh /opt/myscript/myscript2.sh > /tmp/myscript2.check.out" >>*/15 * * * * /bin/sh /opt/myscript/myscript.sh > /tmp/myscript.check.out
crontab */15 * * * * /bin/sh /opt/myscript/myscript.sh > /tmp/myscript.check.out