3

I need to generate the cron expression based on milliseconds. For example: what will be the cron expression for 86400(milliseconds) and how to get the expression..? Please help..

Thanks...

1
  • 1
    86400 is the number of seconds in a day. It has nothing to do with milliseconds.
    – Daniel Beck
    Mar 6, 2012 at 11:06

1 Answer 1

5

cron is not intended for high-accuracy timing ! Forget about seconds or even milliseconds precision here. The best you can get is minutes.

cron CAN be and is frequently off by several seconds (due to process start-up, ...).

If you really require that kind of precision, you should build your own daemon (unless I got your question wrong).


If your intend is "just" to convert second/millisecond time to crontab expression. Then:

  • I assume these jobs are daily jobs, that is <second_number> < 84600
  • 1st arg = minutes of the hour = int( (<second_number> % 3600) / 60)
  • 2nd arg = hours of the day = int( (<second_number> / 3600) )
  • 3rd arg = every day of the month = *
  • 4th arg = every month of the year = *
  • 5th arg = every day of the week = *

For more have look at the crontab man page.

1
  • my concern is.. i have a table containing trigger timings for different jobs.. i need to get the cron expression for those triggers from that table.. but that table contains a column which has time in seconds/millisecond(86400).. so cant we get cron expression for the trigger based on particular column containing timings..?
    – kiran
    Mar 6, 2012 at 10:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .