How to efficiently back up and restore crontab
[oracle@racnode-dc1-1 ~]$ crontab -l */05 * * * * /bin/date > /tmp/date.out 2>&1 */15 * * * * /bin/date > /tmp/date.out 2>&1 #*/25 * * * * /bin/date > /tmp/date.out 2>&1 */35 * * * * /bin/date > /tmp/date.out 2>&1 */45 * * * * /bin/date > /tmp/date.out 2>&1 */55 * * * * /bin/date > /tmp/date.out 2>&1Backup crontab and display contents. Extra precaution in case crontab.save.dinh is removed.
[oracle@racnode-dc1-1 ~]$ crontab -l > crontab.save.dinh; cat crontab.save.dinh */05 * * * * /bin/date > /tmp/date.out 2>&1 */15 * * * * /bin/date > /tmp/date.out 2>&1 #*/25 * * * * /bin/date > /tmp/date.out 2>&1 */35 * * * * /bin/date > /tmp/date.out 2>&1 */45 * * * * /bin/date > /tmp/date.out 2>&1 */55 * * * * /bin/date > /tmp/date.out 2>&1Remove crontab.
[oracle@racnode-dc1-1 ~]$ crontab -r; crontab -l no crontab for oracleRestore crontab.
[oracle@racnode-dc1-1 ~]$ crontab crontab.save.dinh; crontab -l */05 * * * * /bin/date > /tmp/date.out 2>&1 */15 * * * * /bin/date > /tmp/date.out 2>&1 #*/25 * * * * /bin/date > /tmp/date.out 2>&1 */35 * * * * /bin/date > /tmp/date.out 2>&1 */45 * * * * /bin/date > /tmp/date.out 2>&1 */55 * * * * /bin/date > /tmp/date.out 2>&1If you are lazy like me, then backup can be done in one command.
[oracle@racnode-dc1-1 ~]$ crontab -l > crontab.save.dinh; cat crontab.save.dinh; crontab -r; crontab -l */05 * * * * /bin/date > /tmp/date.out 2>&1 */15 * * * * /bin/date > /tmp/date.out 2>&1 #*/25 * * * * /bin/date > /tmp/date.out 2>&1 */35 * * * * /bin/date > /tmp/date.out 2>&1 */45 * * * * /bin/date > /tmp/date.out 2>&1 */55 * * * * /bin/date > /tmp/date.out 2>&1 no crontab for oracle [oracle@racnode-dc1-1 ~]$
On this page
Share this
Share this
More resources
Learn more about Pythian by reading the following blogs and articles.
Using Sed For Search and Replace
Using Sed For Search and Replace
Feb 11, 2021 12:00:00 AM
2
min read
Detect and Notify Linux Server Restart
Detect and Notify Linux Server Restart
Feb 19, 2021 12:00:00 AM
1
min read
How to remove grid 12.2 after an 18c upgrade
How to remove grid 12.2 after an 18c upgrade
May 13, 2019 12:00:00 AM
4
min read
Ready to unlock value from your data?
With Pythian, you can accomplish your data transformation goals and more.