problem with sleep cmd in execution of cron...

I am scheduling a task at regular intervals at seconds acuracy using crond and sleep command . my data in crontab file is as below:-

the above line is working fine when we are creating this crontab file before 00:05 min .
But when we are creating the crontab file at 00:05min , unable to execute sleep cmd. But the next cmd "/usr/local/bin/set_radio_cron grp0 0 0" is able to execute.

please guide me in this. what may be the problem? where i have to modify to make it work?
[as frm 00:05:00 to 00:05:59 has 1min duration and if i create the crontab file between this duration what will be the significance?]
Thanks in advance..

What do you mean "unable to execute the sleep cmd"? What does it actually do?

I mean that when the crontab file is created at 00:05:00 and executed at the same time. the " sleep 45 " command is not running and directly the second command is running. i.e "/usr/local/bin/set_radio_cron grp0 00 & "

I think now it is clear.

The significance is that the next time cron will look at the line you changed will be tomorrow at 00:05. To be safe you really needed to complete the change to crontab by 00:04 .

The highlighted comma and ampersand are neither needed nor desirable.

@ above

But actually when i am creating the crontab file in-between 00:05:00 to 00:05:59 the second command is being executed but the 1st command i.e sleep 45 is not running.

I hope you have removed &

Secondly, are you sure that Sleep command did not get executed?

I didn' t get u.
where I have to keep "&" .

In your given Crontab Entry:

05 00 * * 0,4,5,6, sleep 45 && /usr/local/bin/set_radio_cron grp0 0 0 & 

I can see there is & and one extra comma marked red there.

In above the sleep command is not working but the other command "/usr/local/bin/set_radio_cron grp0 0 0" is working for only below condition.
-> when present time is hr 00:05:12 sec , given time hr 00:05:00 sec

The above quoted command is working fine when :
-->when present time is hr 00:04:12 sec , given time hr 00:05:00 sec

please comment on above ...

If I understand this discussion properly, you are creating a crontab "on the fly", perhaps just one minute before it is timed to run? Why?

Crontabs are normally set up and left alone. The crontabs are read into memory when the kernel boots and the last modified date/time of the crontab is also remembered. "Periodically" the cron daemon will inspect the crontabs to see if anything has changed (by looking at the last modified date/time) and if it has, it will reload that table. Therefore, to my mind, there is no guarantee that a crontab created one minute before it is due to run will be executed one minute later. The cron daemon might not have seen the change by then.

Can any other forum members confirm what I've just said please.

@manoj424
The cron fires at 05:00 exactly, precisely, and to the millisecond.
Any change you make after that time is too late.
Get it?

I agree that you should also give cron a minute or more to see the change. This varies from system to system. The benchmark would be the second the "crontab -e" command finishes.
There is no way that a change made after 05:00 to a cron scheduled at 05:00 would be actioned until the following day.