Unix/Linux Go Back    


UNIX for Beginners Questions & Answers If you're not sure where to post a Unix or Linux question, post it here. All unix and Linux beginners welcome in this forum!

Cronjob

UNIX for Beginners Questions & Answers


Reply    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 03-02-2018   -   Original Discussion by Nishit
Nishit's Unix or Linux Image
Nishit Nishit is offline
Registered User
 
Join Date: Jan 2018
Last Activity: 8 March 2018, 2:02 PM EST
Posts: 6
Thanks: 1
Thanked 0 Times in 0 Posts
Tools Cronjob

How to set cronjob for 48 hours.

I can set for 2 days as shown below.
* * */2 * *

It is creating confusion for 30 days & 31 days per month.
Sponsored Links
    #2  
Old Unix and Linux 03-02-2018   -   Original Discussion by Nishit
MadeInGermany's Unix or Linux Image
MadeInGermany MadeInGermany is offline Forum Staff  
Moderator
 
Join Date: May 2012
Last Activity: 23 April 2018, 9:35 AM EDT
Location: Simplicity
Posts: 4,037
Thanks: 346
Thanked 1,358 Times in 1,224 Posts
Set it to daily, and let the cron job skip every second time.
Example:


Code:
59 23 * * *  tf=/tmp/tf; if [ -d $tf ]; then rmdir $tf; /path/to/realcronjob; else mkdir $tf; fi

As root the protected /var/run/ is safer than /tmp/.
The Following 2 Users Say Thank You to MadeInGermany For This Useful Post:
hicksd8 (03-02-2018), Nishit (03-02-2018)
Sponsored Links
    #3  
Old Unix and Linux 03-13-2018   -   Original Discussion by Nishit
shajay12's Unix or Linux Image
shajay12 shajay12 is offline
Registered User
 
Join Date: Mar 2018
Last Activity: 30 March 2018, 12:14 AM EDT
Posts: 15
Thanks: 2
Thanked 0 Times in 0 Posts
this below cron will work.

0 0 2-31/2 * * command2
    #4  
Old Unix and Linux 03-13-2018   -   Original Discussion by Nishit
MadeInGermany's Unix or Linux Image
MadeInGermany MadeInGermany is offline Forum Staff  
Moderator
 
Join Date: May 2012
Last Activity: 23 April 2018, 9:35 AM EDT
Location: Simplicity
Posts: 4,037
Thanks: 346
Thanked 1,358 Times in 1,224 Posts
Quote:
Originally Posted by shajay12 View Post
this below cron will work.

0 0 2-31/2 * * command2
When the calendar days are 28,29,30,31,1,2,3,4 it will run the red days, and you see that the "every second day" rule is violated.
Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to cancel a cronjob if the cronjob still running 2j4h UNIX for Dummies Questions & Answers 7 08-18-2010 08:16 AM
cronjob maooah AIX 1 02-24-2010 07:28 AM
Cronjob MisterKhan Shell Programming and Scripting 11 03-05-2009 02:58 PM
at vs cronjob mokkan Solaris 1 05-16-2008 11:50 PM
CronJob hcng08 HP-UX 1 08-01-2006 10:44 PM



All times are GMT -4. The time now is 11:33 AM.