Here the commands you need to work with crontab. Explained with sample data and these work in Ubuntu.
IN THIS PAGE
- What is Crontab
- How to List and Edit crontab
- How to add job to crontab
- How to Backup and Replace crontab
- What is Timezone in Crontab
What is Crontab
Crontab in Ubuntu automates shell scripts. Here is my earlier post on this topic. In Ubuntu or any other Linux operating system, the crontab allows for edits only to root users. The sudo users usually are root users.
How to List and Edit crontab
Here are four ridiculously useful commands that you can use while working with Crontab. These are list, edit, backup, and replace commands.
List command
You can view jobs with the list command.
$sudo crontab -l # browse
Edit command
You can edit the Crontab with the edit command.
$sudo crontab -e #edit
How to add job to crontab
To show how to add a cron job, I have added a simple job, which creates a directory at the specified time.

Example cron job
The job runs at 15 minutes, at 20 hours, on 30th, July (7th ), and Saturday, execute command is mkdir srini. A directory of srini creates after running this crontab command.
How to Backup and Replace crontab
Backup command
Here is a command you can use to take the backup of Crontab.
Replace command
Taking backup is the best practice before making changes to the Crontab. The following command replaces the current set of jobs with the jobs in the file crontab.new:
$ crontab -r > crontab.new
What is Timezone in Crontab
Please note that Crontab triggers scripts according to your operating system’s Timezone.
Related
You must be logged in to post a comment.