steps to use cron

Help Link: Ubuntu Help

What is Cron?

Cron is a daemon used for scheduling tasks to be executed at a certain time. Each user has a crontab file, allowing them to specify actions and times that they should be executed. There is also a system crontab, allowing tasks such as log rotation and locate database updating to be done regularly.

What Is Crontab?

A crontab is a simple text file that holds a list of commands that are to be run at specified times. These commands, and their related run times, are controlled by the cron daemon and are executed in the system’s background. More information can be found by viewing the crontab’s man page.

Assume that you have command and you want to run that command at an specified time

for example I have made a sh file with this line

mkdir /home/tareqCron

saving the file naming

from terminal you can test it by running to run it just go to the folder where you saved. Then type:


it will create a directory at /home

now delete the directory. we want to create the director at 2 am everynight

Steps to use cron :

1. open terminal

2.type crontab -e. This will open an editor where we can write crontab commands

3.the format of the line is this :

minute (0-59), hour (0-23, 0 = midnight), day (1-31), month (1-12), weekday (0-6, 0 = Sunday), command

for our example we will add this line
00 02 * * * sh /path_to_saved_sh_file/

4. Now Press ctrl+O
5. press enter

Now go to sleep by running on the machine .. and wake up at 2 am at night
you will see a directory is created at /home ..
that means the command is executing at fixed time
for more example ask google ..


Work is fun!

Tagged with: , , , ,
Posted in Uncategorized
One comment on “steps to use cron

Leave a Reply

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

You are commenting using your 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

All content provided on this "" blog is for informational purposes only. The owner of this blog makes no representations as to the accuracy or completeness of any information on this site or found by following any link on this site. The owner of [] will not be liable for any errors or omissions in this information nor for the availability of this information. The owner will not be liable for any losses, injuries, or damages from the display or use of this information.
October 2008
« Sep   Nov »

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 23 other followers

%d bloggers like this: