Register
It is currently Wed Nov 22, 2017 5:23 am

cronhelp – a syntax reminder for crontab


All times are UTC


Post new topic Reply to topic  [ 2 posts ] 
Author Message
 PostPosted: Fri Aug 22, 2014 12:28 am   
Site Admin
User avatar

Joined: Thu Apr 17, 2003 3:44 am
Posts: 12299
Location: Iowa
https://crouse.us/?p=18

One of the things an admin needs to know how to do quickly, is setup cronjobs. This is of course done using the crontab -e command. The syntax is hard for some to remember and instead of going to google and searching every time I needed to know the syntax again, years ago I created a small simple shell script called “cronhelp” that I stuck into /usr/local/bin/cronhelp

Then all I would have to do is type “cronhelp” on the command line and my simple help file would display.

Code:
#!/bin/bash
crontab ()
{
### cron - Displays a cron help file.
echo " "
echo "Crontab Example/Hints  "
echo "---------------------------------------------------------------"
echo "# +---------------- minute       (0 - 59)"
echo "# |  +------------- hour         (0 - 23)"
echo "# |  |  +---------- day of month (1 - 31)"
echo "# |  |  |  +------- month        (1 - 12)"
echo "# |  |  |  |  +---- day of week  (0 - 7)  (Sunday=0 or 7)"
echo "# |  |  |  |  |"
echo "# *  *  *  *  *  command"
echo "---------------------------------------------------------------"
echo " "
}
crontab
exit 0

_________________

Zbook (Laptop)- Mint 18 64-bit - I7-4800mq - 32GB ram
Phantom (Desktop)- Mint 64-bit - i7-5770 - 32GB ram
Nas4Free (NAS) - 6X3TB File Server.
Sky (HP BladeCenter) - 16 blades - 536 GB ram-G7/G6/G5 blades.


Top
 Profile WWW  
 PostPosted: Fri Sep 05, 2014 2:52 am   
Site Admin
User avatar

Joined: Thu Apr 17, 2003 3:44 am
Posts: 12299
Location: Iowa
man 5 crontab

Very helpful.......
Some pretty cool options alot of people overlook....
Quote:
Instead of the first five fields, one of eight special strings may
appear:

string meaning
------ -------
@reboot Run once, at startup.
@yearly Run once a year, "0 0 1 1 *".
@annually (same as @yearly)
@monthly Run once a month, "0 0 1 * *".
@weekly Run once a week, "0 0 * * 0".
@daily Run once a day, "0 0 * * *".
@midnight (same as @daily)
@hourly Run once an hour, "0 * * * *".


_________________

Zbook (Laptop)- Mint 18 64-bit - I7-4800mq - 32GB ram
Phantom (Desktop)- Mint 64-bit - i7-5770 - 32GB ram
Nas4Free (NAS) - 6X3TB File Server.
Sky (HP BladeCenter) - 16 blades - 536 GB ram-G7/G6/G5 blades.


Top
 Profile WWW  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


Powered by phpBB © 2012 phpBB Group
© 2003 - 2012 USA LINUX USERS GROUP