Key aspect gain from unix based system is the amount of customization you can go for (In windows 7 even for adding a route you should run command prompt as administrator). I am neither Linux lover nor windows hater. But this gives us the ability to change, test the system in a fun way where you play with software the way you want.
See crontab. Great tool that exist inside unix based systems. We do use for numerous tasks otherwise need lot of development effort. Simplicity and flexibility makes this as a very powerful tool in linux.
Syntax is as below
* * * * * command/script file to be executed
- - - - -
| | | | |
| | | | +----- day of week (0 - 6) (Sunday=0)
| | | +------- month (1 - 12)
| | +--------- day of month (1 - 31)
| +----------- hour (0 - 23)
+------------- min (0 - 59)
Simple example
0 * * * * sh /home/kasun/scripts/bin/test.sh
- This will run every hour on 00(zero) minutes.
Make it run in every 5 minutes interval
1-59/5 * * * * sh home/kasun/scripts/bin/test.sh
Same can be applied for all the fields (min, hour, day of month, month, day f week)
Very simple isn’t it? Or if you need just put the unix based command to the crontab. Direct the output to log file so you can check it later.
Under vi you can use following commands for cronjob modifications on shell.
crontab -e Edit your crontab file, or create one if it doesn’t already exist.
crontab -l Display your crontab file.
crontab -r Remove your crontab file.
crontab -l Display your crontab file.
crontab -r Remove your crontab file.
Including >/dev/null at the end of command will make sure no output from cronjob. And make sure the script/command result no errors. Otherwise it will send an email using sendmail.
If you have so many cronjobs (Especially on production system) this will make some troubles. If the sendmail is not properly configured all of the mails will queue inside /va/spool/mqueue. This will cause to hard disk space problems, inode limitations.
df –h
df –i
Above commands may helpful in identifying those problems.
No comments:
Post a Comment