How do I get my crontab back?

How do I get my crontab back?

You can try to have a look at /var/log/cron and build your crontab again.

  1. Have a look at the logfile.
  2. Take the first command and do grep commandname1 /var/log/cron.
  3. Figure out the systematic behind the times the command was run.
  4. put that entry to your new crontab.
  5. execute cat /var/log/cron | grep -v commandname1.

How do I find deleted cron jobs?

4 Answers

  1. On RedHat/CentOS, if your jobs have been triggered before, you can find the cron log in /var/log/cron . The file will help you rewrite the jobs again.
  2. Another option is to recover the file using a file recovery tool.
  3. On Ubuntu/Debian, if your task has run before, try grep CRON /var/log/syslog.

Where are crontab files stored?

The crontab files are stored in /var/spool/cron/crontabs . Several crontab files besides root are provided during SunOS software installation (see the following table). Besides the default crontab file, users can create crontab files to schedule their own system events.

How to recover cron jobs accidentally removed by crontab-R?

crontab -r removes the only file containing the cron jobs. So if you did not make a backup, your only recovery options are: On RedHat/CentOS, if your jobs have been triggered before, you can find the cron log in /var/log/cron. The file will help you rewrite the jobs again. Another option is to recover the file using a file recovery tool.

Where can I find the user crontab file?

The user crontab files are located in /var/spool/cron/crontabs, but their permissions are set in such a way that they can’t be traversed to without superuser permission (but once open and the cron process drops privileges it can still access the file).

Can you save crontab editor after making changes?

But only saving crontab editor after making some changes does not work. You must leave the editor to reflect changes in cron. After exiting new entry appears in the log: From this point changes you made are visible to CRON. Not the answer you’re looking for?

Do you need root to run crontab tasks?

Yes, and it will run with the privileges of that user account. As a principle, it is best to run scheduled tasks with the lowest privileges you can get away with, so if what you are doing will not require root, don’t use root.