Operating System - HP-UX
1820475 Members
2910 Online
109624 Solutions
New Discussion юеВ

Run command every 5 minutes

 
Sanjeev gupta_2
Frequent Advisor

Run command every 5 minutes

Hi
How can i add in cron to run a command after every 5 minutes
i Read from a web page that u can do this by this:
*/5 * * * * command
But it is not working. will it work on HP-UX
Or i have to use following:-

0,5,10,15,20,25,30,35,40,45,50,55 * * * * command

Pl. suggest on it

Thx
sanjeevg
10 REPLIES 10
Robert Salter
Respected Contributor

Re: Run command every 5 minutes

0,5,10,15,20,25,30,35,40,45,50,55 * * * * command

this will work
Time to smoke and joke
Pete Randall
Outstanding Contributor

Re: Run command every 5 minutes

Your second attempt should work

0,5,10,15,20,25,30,35,40,45,50,55 * * * * command


Pete

Pete
Dave La Mar
Honored Contributor

Re: Run command every 5 minutes

Sanjeevg-
You can do the last, but you can also simply start the script and have a loop condition where it sleeps 300 (five minutes) then repeats . This can be set to stop at any given time, preferably just prior to your next cron execution of it.
Many options, I'm sure you'll get a response you can use.

Best of luck.

Regards,

dl
"I'm not dumb. I just have a command of thoroughly useless information."
Jeroen Peereboom
Honored Contributor

Re: Run command every 5 minutes

Sanjeev,

use cron to schedule a job every 5 minutes.
You need 0,5,10,15,20,25,30,35,40,45,50,55 * * * * command

Be aware, cron jobs have a limited environment setting. You may need to set your PATH and so on. Read the manpages.

The */5 construct is typical Linux cron.

If you use sleep 300, your job will sleep for 5 minutes, so it will start 5 minutes + the time it needed for execution later than the previous run. It would not be my first choice.

JP
Hoang Minh Tuan
Regular Advisor

Re: Run command every 5 minutes

Sanjeev,

The second is the true format to run a command every 5 minutes.

The format of cron job is:
minute hour day month date command

HMT
Bus wait at bus station, Work wait at my work station
Nguyen Anh Tien
Honored Contributor

Re: Run command every 5 minutes

1, Check cron log and find error code.
#vi /var/adm/cron/log
2, command must be write in full format
*/5 * * * * /sbin/sh /path/yourshell
HP is simple
Ravi_8
Honored Contributor

Re: Run command every 5 minutes

Hi

#crontab -e
will open the crontab file
0,5,10,15,20,25,30,35,40,45,50,55 * * * * command

will run the command once in every minutes
never give up
Thierry Poels_1
Honored Contributor

Re: Run command every 5 minutes

hi,

*/5 is Linux syntax and is not supported on HP-UX.

So on HP-UX you'll need to specify the exact times you want the job to run:
0,5,10,15,...
or 1,6,11,16,... whatever.

Maybe we'll get the */n syntax in a new HP-UX release some day.

regards,
Thierry.
All unix flavours are exactly the same . . . . . . . . . . for end users anyway.
Cem Tugrul
Esteemed Contributor

Re: Run command every 5 minutes

Hi,

Firstly,if this command will be run for a none root user then you have to modify
/var/adm/cron/cron.allow file and add this
user then;
an example of my user who is running on ksh so;

0,5,10,15,20,25,30,35,40,45,50,55 * * * * (/usr/bin/ksh command)

Believe me mine is working properly...

Good Luck,
Our greatest duty in this life is to help others. And please, if you can't
Silver_1
Regular Advisor

Re: Run command every 5 minutes

I were you, will go for your second choice.

Tx
Nair