Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
TetraWiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Linux 101 hacks
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=='''Hack 74. Crontab'''== Using cron you can execute a shell-script or Linux commands at a specific time and date. For example a sysadmin can schedule a backup job that can run every day. '''How to add a job to the cron?''' <nowiki># </nowiki>crontab βe 0 5 <nowiki>* </nowiki><nowiki>* </nowiki><nowiki>* </nowiki>/root/bin/backup.sh This will execute /root/bin/backup.sh at 5 a.m every day. '''Description of Cron fields.''' Following is the format of the crontab file. {minute} {hour} {day-of-month} {month} {day-of-week} {full-path-to-shell-script} o minute: Allowed range 0 β 59 o hour: Allowed range 0 β 23 o day-of-month: Allowed range 0 β 31 o month: Allowed range 1 β 12. 1 = January. 12 = December. o Day-of-week: Allowed range 0 β 7. Sunday is either 0 or 7. '''Crontab examples''' # Run at 12:01 a.m. 1 minute after midnight everyday. This is a good time to run backup when the system is not under load. # ## 0 <nowiki>* </nowiki><nowiki>* </nowiki><nowiki>* </nowiki>/root/bin/backup.sh # Run backup every weekday (Mon β Fri) at 11:59 p.m. # ## 11 <nowiki>* </nowiki><nowiki>* </nowiki>1,2,3,4,5 /root/bin/backup.sh Following will also do the same. 59 11 <nowiki>* </nowiki><nowiki>* </nowiki>1-5 /root/bin/backup.sh # Execute the command every 5 minutes. <nowiki>*/5 </nowiki><nowiki>* </nowiki><nowiki>* </nowiki><nowiki>* </nowiki><nowiki>* </nowiki>/root/bin/check-status.sh # Execute at 1:10 p.m on 1st of every month # ## 13 1 <nowiki>* </nowiki><nowiki>* </nowiki>/root/bin/full-backup.sh # Execute 11 p.m on weekdays. # ## 23 <nowiki>* </nowiki><nowiki>* </nowiki>1-5 /root/bin/incremental-backup.sh '''Crontab Options ''' Following are the available options with crontab: # crontab βe : Edit the crontab file. This will create a crontab, if it doesnβt exist o crontab βl : Display the crontab file. o crontab -r : Remove the crontab file. o crontab -ir : This will prompt user before deleting a crontab.
Summary:
Please note that all contributions to TetraWiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
TetraWiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)