LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-10-2012, 05:40 AM   #1
apss_evaluator
Member
 
Registered: Mar 2012
Posts: 115

Rep: Reputation: Disabled
run a cron every second day


Hi guy's

I've been searching a procedure on how can I run a command every 11:59 midnight every in every 2nd day interval. sample today is monday it will run on 11:59 pm and the run will be tuesday of 11:59 pm.


I've been looking for samples in google but I havent found any. just hourly, daily, weekly and monthly schedules.


Thanks in advance
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 05-10-2012, 05:45 AM   #2
Satyaveer Arya
Senior Member
 
Registered: May 2010
Location: Palm Island
Distribution: RHEL, CentOS, Debian, Oracle Solaris 10
Posts: 1,415

Rep: Reputation: 305Reputation: 305Reputation: 305Reputation: 305
Quote:
sample today is monday it will run on 11:59 pm and the run will be tuesday of 11:59 pm.
It means that you want to run the command everyday at 11:59 PM.

Here is an example site for you - cronjob exmpales.
Now you can try with the help of those examples by understing cron and cronjob.
 
Old 05-10-2012, 08:43 AM   #3
Steviepower
Member
 
Registered: May 2010
Location: Eindhoven
Distribution: ubuntu/debian
Posts: 152

Rep: Reputation: 25
maybe run it every 48 hour? see http://www.adminschoice.com/crontab-quick-reference
and I'm just assuming you mean monday and wednesday?
 
Old 05-10-2012, 08:44 AM   #4
Steviepower
Member
 
Registered: May 2010
Location: Eindhoven
Distribution: ubuntu/debian
Posts: 152

Rep: Reputation: 25
I also found this: http://www.absolutewillynilly.com/we...ob-run-2-days/
 
Old 05-10-2012, 03:03 PM   #5
Babertje
Member
 
Registered: Jun 2009
Location: Haarlem, The Netherlands
Distribution: Archlinux
Posts: 125

Rep: Reputation: 20
There is also a trick to let the cronjob store the unix time in seconds after a completed job in a timestamp log file just let it run each day and If the difference is less than 172000 seconds you let it skip the job not updating the timestamp file. And If it is greater than 172000 you let it run and overwrite the timestamp log with a new one
 
Old 05-10-2012, 03:15 PM   #6
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604

Rep: Reputation: 415Reputation: 415Reputation: 415Reputation: 415Reputation: 415
Why not just:

Code:
  .---------------- minute (0 - 59)
#  |   .------------- hour (0 - 23)
#  |   |   .---------- day of month (1 - 31)
#  |   |   |   .------- month (1 - 12) OR jan,feb,mar,apr ...
#  |   |   |   |  .----- day of week (0 - 7) (Sunday=0 or 7)  OR sun,mon,tue,wed,thu,fri,sat
#  |   |   |   |  |
#  *   *   *   *  *  command to be executed
   *   *   */2 *  *  /your/command/here.sh
 
2 members found this post helpful.
Old 05-10-2012, 07:22 PM   #7
Babertje
Member
 
Registered: Jun 2009
Location: Haarlem, The Netherlands
Distribution: Archlinux
Posts: 125

Rep: Reputation: 20
With a timestamp based script it doesn't care if you restarted the machine.
Added an example script for desktop usage for running a backup job each 48 hours even if you don't use the computer for 3 days it will take action on that thirth day. This script just needs to be called by cron.daily
skip_a_day.cron.sh.tar.gz

Last edited by Babertje; 05-11-2012 at 05:48 AM.
 
Old 05-11-2012, 03:21 AM   #8
Steviepower
Member
 
Registered: May 2010
Location: Eindhoven
Distribution: ubuntu/debian
Posts: 152

Rep: Reputation: 25
with the every second day */2 option in crontab it shouldn't be hard to do either
 
Old 05-11-2012, 11:54 AM   #9
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 3,158

Rep: Reputation: 1356Reputation: 1356Reputation: 1356Reputation: 1356Reputation: 1356Reputation: 1356Reputation: 1356Reputation: 1356Reputation: 1356Reputation: 1356
Quote:
Originally Posted by Steviepower View Post
with the every second day */2 option in crontab it shouldn't be hard to do either
That's if you don't mind a little glitch in the sequence following each month that has an odd number of days.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
cron for last day of month dhar Linux - Newbie 7 11-14-2009 02:45 PM
cron job: day of month / day of week conflict? geekpie Linux - General 2 10-21-2009 04:56 AM
cron - finding last day of month FormalLogic Linux - General 7 03-10-2009 02:16 PM
Can you restore a cron from previous day? Rustylinux SUSE / openSUSE 1 01-15-2007 06:07 PM
cron last day of every month lobo78 Linux - General 2 03-03-2004 09:41 PM


All times are GMT -5. The time now is 01:35 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration