This content has been marked as final. Show 13 replies
every 40days i think its not possible using cron............
nearest you can think of running by-monthly or running on particular day for every 2 months........
#If i am not wrong below cron schedule runs on 15th for every 2 months once
* * 15 */2 */usr/bin/date >> /home/oracle/scriptlog
#runs for every 2 months
* * * */2 * /usr/bin/date >> /home/oracle/scriptlog
877938 wrote:i dont think you can accomplish it even using AT.............
Thanks for your reply.
Can it be possible using AT (linux scheduler)?
however what are you trying to schedule.................if its something related to oracle and if you are open to oracle then you can think of using dbms_scheduler for that............a pretty impressive one........i went through oracle docs, scheduling a job for every 40 days seems possible :)
Edited by: Veeresh.S on Nov 13, 2012 5:43 PM
There are alternative options. For instance, you could schedule a script to run daily and program it to check and increment a counter, saved and maintained in a file. This would also allow cron to pickup the correct remaining days for your schedule after a system restart. Or schedule crontasks using fixed dates instead of specifying an interval.
Dude wrote:But that would be once a month, just 10 days later than the day of the month you have your cron job set to run.
I have never tried it, but it may work to combine cron with at, e.g. to create a cron task that runs once a month and uses at to delay the execution for another 10 days.
Edited by: Dude on Nov 14, 2012 9:10 AM
I think one way to do it so that the job automatically repeats would be for your "at" job to resubmit itself to run in 40 days.
You are right. One might as well schedule the task for the 10th of each month. That was quite silly, I wasn't thinking. ;-(
Well, seems the best way might be to use at to submit a job that continues to re-submit itself again, as previously noted a couple of times (seeing it now). Or create 9 tasks in cron that run on a fixed date, which I wrote before. Think I'd rather use the later, which is more obvious than running something in the back or something one might forget about later.
Yeah, an "at" job sitting out there running itself every 40 days isn't going to be easy to keep track of.
On Linux the "date" utility supports the "+%s" format, which is seconds since the epoch. Divide that by 86400 and you have days since the epoch. Something like this:
Put that in a cron job, and if the remainder is whatever single value you pick, run your job. Else do nothing.
#!/bin/bash now=`date "+%s"` today=$(( $now / 86400 )) rem=$(( $today % 40 ))
That will run every 40 days.
The "%s" format specification to the date utility is a non-POSIX extension, so it's not available on strictly POSIX-compliant systems. Though it's pretty trivial to write something in C that will emit the current time in seconds since epoch. Perl probably can be used, too.