Search

User login

Poll

What is your favorite DB Server ?:
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
4 + 8 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.

My YM

Author Information

sentono
Offline
Last seen: 2 weeks 6 days ago
Joined: 09/21/2007

Alexa Rank

Who's online

There are currently 0 users and 10 guests online.
Home
The page you requested does not exist. A search for OR 23 resulted in this page.
  • warning: Invalid argument supplied for foreach() in /usr/home/wowtutorial/public_html/sites/all/modules/adsense_injector/adsense_injector.module on line 352.
  • warning: Invalid argument supplied for foreach() in /usr/home/wowtutorial/public_html/sites/all/modules/adsense_injector/adsense_injector.module on line 35.

Automation Using Linux Crontab to Schedule Task


If you want to run some processes like backup , generate image thumbnail etc.. in the background.
The is an easy way to do this, we can using Crontab to handle this task so it will automatically do the job in your schedule task.

What is Crontab ?

Crontab is found in unix and unix-like O/S, cron derives from chronos greek time and it used to schedule command or execute it periodically.


How to Verify Crontab Running in The System ?

Login into your server and type this command below :

#crontab -l

### you will see someline like example below ###

* * * * * /bin/example-path/example-script.sh


So How To Add a Schedule Task to Crontab ?

Still in your terminal / ssh terminal, type this command below

#crontab -e

You will see a blank screen, you can press INSERT button and start type your crontab command
after that don't forget to save your crontab, press ESC button and type :wq! this will help you save your crontab to the schedule task


Crontab Schedule Explain

Example : * * * * * /bin/testing-path/testing-script.sh

You can see a 5 stars there, the stars will present a different minute, hour, day of month, month and day of week.

  1. minute (from 0 to 59)
  2. hour (from 0 to 23)
  3. day of month (from 1 to 31)
  4. month (from 1 to 12)
  5. day of week (from 0 to 6) (0=Sunday)

From the example above the crontab will execute every minute.

Note :

* / star/ asterisk mean EVERY


Another Crontab Example

If you want to run a schedule script at 2AM every Thursday, then you need a following cronjob

0 2 * * 4  /bin/testing-path/testing-script.sh

Example Star Description above:

  1. minute: 0
  2. of hour: 1
  3. of day of month: * (every day of month)
  4. of month: * (every month)
  5. and weekday: 1-5 (=Monday til Friday)

 

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.

Recent comments

Facebook Fans

Sponsors

Online Store

Tag Cloud