Q. How do I run a cron job or a shell script every 10 minutes using Linux / UNIX cron service?
A. cron is a time-based scheduling service in Linux / Unix-like computer operating systems.
Login to UNIX system
Type the following command to enter cronjob:
$ crontab -e
Each cronjob has following syntax:
# +---------------- minute (0 - 59) # | +------------- hour (0 - 23) # | | +---------- day of month (1 - 31) # | | | +------- month (1 - 12) # | | | | +---- day of week (0 - 6) (Sunday=0 or 7) # | | | | | * * * * * command to be executed
To get crontab to run a task every 10 minutes you could type as follow
*/10 * * * * /path/to/command
Save and close the file.
You should follow me on twitter here or grab rss feed to keep track of new changes.
Featured Articles:
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop













{ 11 comments… read them below or add one }
*/10 * * * * /home/test.sh > /dev/null 2>&1
crontab: error on previous line; unexpected character found in line.
crontab: errors detected in input, no crontab file generated.
Guess it does not work in Solaris 8
OR
sudo -i
cd /etc/cron.d
touch command
vi command
# in command file
MAILTO=rootmail@foo.bar
*/10 * * * * /path/to/command
# save command file and exit
if you do not want to receive a letter then
MAILTO=”"
yeah, budacsik. why use one command when you can use 4 :)))
yes, just one line
sudo vi /etc/cron.d/command
what if I need to start the script at 3:00 AM exactly and consecutive executions should begin after every 10 mins.
eg: 3:00 3:10 3:20 etc… lifetime
But the clause is, it should start exactly at 3:00. I can play in scripts. But is there an option like this in crons?
*/10 3,4,5 * * *
It will be called
WHEN ( MINUITES DIVIDED BY 10 AND DIVISION REMAINDER EQUALS 0
AND
( HOUR EQUALS 3 ) OR ( HOUR EQUALS 4 ) OR ( HOUR EQUALS 5 ) )
So it will run at 3.00, 3.10, 3.20, 3.30, 3.40, 3.50, 4.00, 4.10….. 5.50
so can I go like this to start at 3AM and then by 10 mins invokes would this continue around the clock?
*/10 3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,1,2 * * *
*/10 3-24 * * *
you can define ranges within a cron job instead of separating everything with a comma
you can use range instead of separating everything with a comma
i.e */10 3-24 * * *
What this post doesn’t explain is why it works. In a crontab, the / symbol means that it will run if the current value can be divided by the following number without a remainder.
This isn’t important for simple timers like ‘every ten minutes’, but can be very useful when using more advanced calculations.
This is very helpful….thnx everyone. I got my queru answerd without any more search…u gyus rock…!!