×
UNIX.COM Login
Username:
Password:  
Show Password






👤


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

👤 Login to reply

 
Thread Tools Search this Thread Display Modes
    #1  
Old 03-02-2018
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 03-02-2018
MadeInGermany MadeInGermany is offline Forum Staff  
Moderator
 
Join Date: May 2012
Last Activity: 16 July 2018, 4:42 PM EDT
Location: Simplicity
Posts: 4,153
Thanks: 365
Thanked 1,418 Times in 1,274 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 03-13-2018
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 03-13-2018
MadeInGermany MadeInGermany is offline Forum Staff  
Moderator
 
Join Date: May 2012
Last Activity: 16 July 2018, 4:42 PM EDT
Location: Simplicity
Posts: 4,153
Thanks: 365
Thanked 1,418 Times in 1,274 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
👤 Login to reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 09:50 PM.

Unix & Linux Forums Content Copyrightę1993-2018. All Rights Reserved.