Cron jobs in Linux

To create cron jobs in Linux:

Just remember the following syntax
.—————- minute (0 – 59)
| .————- hour (0 – 23)
| | .———- day of month (1 – 31)
| | | .——- month (1 – 12) OR jan,feb,mar,apr …
| | | | .—- day of week (0 – 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
| | | | |
* * * * * user-name command to be executed
1. run crontab -e
and append your command/tasks as following
i.e.
* * * * * python /etc/script.py

2. can also edit crontact file directly
vim /etc/crontab and append your tasks
i.e.
* * * * * root touch filename

To view view cron jobs in Linux:

$ crontab -l

$ cat /etc/crontab

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s