| |
Market Research Strategies for Small Businesses
Category:
Go For Lasik Surgery Chicago Break Free From Glasses
Category:
Billy Ray Cyrus Breaks the Silence
Category:
Who pays for the recycling of batteries?
Category:
Russia Grounds Su-24 Bombers After Crash
Category:
New US Federal Reserve Meeting Spurs Hopes For Another Interest ...
Category:
Pay Day Loans In Washington:
Category:
Information on Shingles
Category:
The Basics of Search Engine Optimization (S.E.O.)
Category:
India, China Conclude Joint Military Exercises
Category:
Metal Gear Solid 4: News and Fun Facts
Category:
Forex currency trading and the Internet
Category:
Adult video chat – larger than life sex
Category:
CRM AND SMALL BUSINESSES
Category:
A Few Things That You Can Do To Increase Gas Mileage Of Yo...
Category:
Options
Category:
International Aid Summit Formally Opens In Jakarta
Category:
Aide to Guatemalan Presidential Candidate Shot Dead
Category:
What's more important than the money in any contract you sign?
Category:
Bodybuilding Diet Mistakes To Avoid At All Costs
Category:
Internet Marketing Strategy: Find Your Niche!
Category:
How To Get Listed In Open Directory Project, The First Time!
Category:
Which TLD
Category:
Ah, Come On Baby, Stop Teasing, Show Me, Show Me, Show Me (Show,...
Category:
Nigerian President Asks Parliament to Impeach VP
Category:
Low rate unsecured loans - your money for everything you need
Category:
Alzheimer's Family Caregiver Support: Perfectionism Can Be Bad ...
Category:
Five Russian Soldiers Killed in Chechnya, 20 Wounded
Category:
Bargain shopping on the net
Category:
Hamas Leader Meets Turkish Officials in Ankara
Category:
Hundreds of Thousands March in Support of Mexico City's Mayor
Category:
US Defends Climate Change Policy Ahead of Sydney Conference
Category:
How to be a Miracle Maker
Category:
China Braces for Cold Winter Amid Energy Shortages
Category:
How to make the most out of "Paid Submissions to Search Engines"
Category:
It's Your Money - Why Wait?
Category:
Compromise Reached on US Anti-Terror Law
Category:
Palestinian Hopes Clash With Realities in 2005
Category:
I'm Not Looking for a Friend, I'm Looking for a Jedi Master
Category:
Types of Virus Infections
Category:
Ideas for Back Pain Remedies
Category:
Identifying the Signs of Breast Cancer
Category:
How To Identify An Allergic Asthma?
Category:
Impotence Help
Category:
Are You Lucky - Or Is It Synchronicity?
Category:
Express yourself to loved ones by online greeting card
Category:
Increase Your Sales By Using Confidence
Category:
Information Security
Category:
Internet Based Home Business - Having A Mobile Office In Your Ho...
Category:
Internet Dating Do's and Don'ts
Category:
UN Hosts Conference on Food Safety in Africa
Category:
Internet Marketing "Secret"-To Making Big Money Fast
Category:
Is It Easy for You?
Category:
Internet Home Based Business Opportunity # 629...
Category:
JIM FINUCAN?S BILL COLLECTING Q AND A, Issue 4
Category:
New York Giants Shock New England Patriots to Win Super Bowl 42
Category:
Keep Time And Cash - Download Your Preferred Linkin Park Music
Category:
Motorcycle Rides Are Thrilling but Accidents Do Happen
Category:
Thousands of Pro-Immigration Advocates Lobby in Washington
Category:
Fibromyalgia- a non-inflammatory form of Arthritis
Category:
Healthcare for Retirees: It's Not a Pretty Picture
Category:
How To Gain Rapport
Category:
Nigeria's Anti-Corruption Chief Ousted
Category:
No Teletrack Short Term Loans: short cut to get the cash.
Category:
Office Desks: Nothing but the Best
Category:
Australian Protesters Claim Win Against Japanese Whalers
Category:
American and Russian Leaders To Meet at White House
Category:
Which Is Better? Internet Home Business Vs Offline Business Comp...
Category:
THIS IS AWESOME!!!
Category:business
The Apprentice - Could you do better?
Category:
Tips To Have a Successful and Profitable Affiliate Marketing Bus...
Category:
3 Strategies For Leveraging The Opportunity Markers In Your Hand...
Category:
Normal Body Mass Index
Category:
US 'War Hawks' Become Iraq War Critics
Category:
Full Economic Costing of Professional Services
Category:
|
|
|
Automating Tasks in Linux using Cro 0 article
Automating Tasks in Linux using Cron
Linux has a powerful task scheduler called Cron.
By Vinu Thomas
Category: 0
Submit your Recipes Here!
Linux has a powerful task scheduler called Cron. Cron will allow you to run commands automatically at times specified by you. Cron is similar to the task scheduler you find in Windows. To keep track of the schedules and tasks it has to run, Cron requires a file called Crontab (CRON TABle). All the Cron schedules and tasks should be stored in this table. The Crontab files cannot be directly edited. You can add or delete entries in the crontab file using the crontab command.
What's Cron and Crontab ?
You must be wondering what the difference between cron and crontab or wether they are the same. Cron is a process or program which wakes up every minute and looks for jobs it has to execute at that moment. Crontab is the list of jobs and times at which they have to execute.
Crontab Format:
Each entry in Crontab has at least 6 fields separated by a single space. Field 1 Minute Range of Values : 0-59 Field 2 Hour Range of Values : 0-23 Field 3 Day Range of Values : 1-31 Field 4 Month Range of Values : 1-12 Field 5 Day of week Range of Values : 0-6 (Sunday being 0) Field 6 Command to Execute
Now let's see how to make a crontab entry. Let's say you want to run a script backup.sh every day at 6:00pm.The entry would look like this:
0 18 * * * /home/user/backup.sh
The asterisk (*) is used to indicate that every instance of the particular time period will be used (i.e. every hour, every weekday, etc.). I've used to full path to the script /home/user/backup.sh instead of just using backup.sh. This is because cron runs as root, you should fully qualify your path names to any scripts that will be run. Let's see some more examples :
* Let's run the script printinvoices.sh every sunday at 12:45pm.
45 12 * * 0 /home/account/printinvoices.sh
* How about clearaccount.sh every month beginning at 1:32am ?
21 1 1 * * /home/accont/clearaccount.sh
* Let's see how to schedule a task to run only on weekdays(monday to friday)
0 10 * * 1-5 /home/account/cleartemp.sh
Adding and Editing Entries in Crontab and Now that you know how crontab entries are formated, it's time to put some of your entries into the crontab list. To do this, you can use the crontab command. By specifying the -e option, you'll be taken to the default text editor to add and edit your crontab list. [crontab -e]
Another method of manipulating your crontab entries is to create and save a text file with your crontab entries. You can load your list into crontab by using the following command: [crontab mycrontablist] where mycrontablist is the file containing your entries.
Viewing Crontab: [crontab -l]
You can view your current crontab list by specifying the -l option. Issuing this command will print out a list of all your current jobs in the crontab list
Removing Crontab: [crontab -r]
The -r option removes your current crontab file. Issuing this command will empty the contents of the current user's crontab file
Output from cron
Usually the output of cron gets mailed to the owner of the process or the person or email id specified in the MAILTO variable. To set the MAILTO variable, you'll have to add the following command to the top of your crontab : MAILTO="your_email_address@domain.com"
If you have a command that is run frequently, and you don't want the output to be emailed each time, you can redirect the output to a log file cmd >> log.file, so your job would be something like this.
0 18 * * * /home/user/backup.sh>>log.file
If you don't want any output at all, you can redirect the output to a null file : cmd>>/dev/null
0 18 * * * /home/user/backup.sh>>/dev/null
About the Author Vinu Thomas is a consultant on Web design and Internet Technologies. His website is http://www.vinuthomas.com. You can read more articles on Linux @ http://www.vinuthomas.com/sections-listarticles-6.html
|