Operating System - HP-UX
1753907 Members
8924 Online
108810 Solutions
New Discussion юеВ

Scheduling cron in Seconds

 
SOLVED
Go to solution
Mohammad Sanaullah
Frequent Advisor

Scheduling cron in Seconds

Hi All Unix Guru!
As in cron we have minimum time scheduling as one minute, is there any way to use the cron for seconds say 30 sec.

help me out whether it is possible or not, if yes then please any general EXAMPLE for the same.

Thanks in Advance,
Points Later
Alive
6 REPLIES 6
Dennis Handly
Acclaimed Contributor
Solution

Re: Scheduling cron in Seconds

No, cron's resolution is minutes.

If you want seconds, you probably shouldn't be stopping and starting your process and just keep it running all the time as a demon.

While at(1) allows you to specify seconds, you can't use seconds for the "next" option.

Arturo Galbiati
Esteemed Contributor

Re: Scheduling cron in Seconds

Hi,
this is possbile using 'at' command. From man at:

-t spectime Define the absolute time to start the job.

spectime A date and time in the format:

[[CC]YY]MMDDhhmm [ . ss ]

where the decimal digit pairs are
as follows:

CC The first two digits of the
year (19, 20).
YY The second two digits of the
year (69-99, 00-68). See
WARNINGS.
MM The month of the year (01-12).
DD The day of the month (01-31).
hh The hour of the day (00-23).
mm The minute of the hour
(00-59).
ss The second of the minute
(00-61).


Man at for further info.
HTH,
Art
Peter Nikitka
Honored Contributor

Re: Scheduling cron in Seconds

Hi,

first you should be shure, that possibly overlapping crobjobs do not occure or are meaningless.
Then you could start two cronjobs:
* hour day month wday /path/to/jobs args
* hour day month wday sleep 30 && /path/to/jobs args

mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"
Tor-Arne Nostdal
Trusted Contributor

Re: Scheduling cron in Seconds

Strange that it haven't been implemented in cron during all these years and same question seems to be popping up from time to time...
...even though the cron daemon checks only once a minute. It could start the job on the appropriate MM and sleep in .ss seconds...

Simple Workaround:
Create a script "delay_cmd"
#!/bin/sh
# Script: delay_cmd
sleep $1
shift
$*

Then run your command with:
delay_cmd 10 mycommand parameters

This would run "mycommand parameters" after sleeping 10 seconds

/Tor-Arne
I'm trying to become President of the state I'm in...
Mohammad Sanaullah
Frequent Advisor

Re: Scheduling cron in Seconds

Dear All,
I was aware that scheduling cron in seconds is not possible in general as minimum frequency for cron is one minute but i was looking for any other simple way to take output from cron in seconds.

please forward me any link have information regarding cron and its functionality.

thanks again for all support
Alive
Yogeeraj_1
Honored Contributor

Re: Scheduling cron in Seconds

hi,

the default man page itself is clear enough, please see:
http://nixdoc.net/man-pages/HP-UX/man1M/cron.1M.html


and also:
http://en.wikipedia.org/wiki/Crontab

hope this helps!

kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)