Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 523
  • Last Modified:

Every Two Week Cron Job

I need a cron that will run every other Monday ( without regard to the number of weeks in a month ).  I have tried:  0 4 * * mon/2  and that ran *every* Monday.

I'd like to avoid creating file - checking for existance of file - deleting file, etc. and just be able to specify the frequency in the crontab.

Any ideas?

Linux version 2.4.18-5 (root@localhost.localdomain) (gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-98))
0
dskhunter
Asked:
dskhunter
  • 2
1 Solution
 
koppchaCommented:
0 4 * * 1/2...This didn't work ?
0 is for sunday and 1 is for monday  
0
 
dskhunterAuthor Commented:
As I said, I used mon/2 and that ran every Monday.  I haven't tried 1/2 but I would expect the same results.
0
 
koppchaCommented:
I think that will work
0
 
wesly_chenCommented:
0 4 * * mon  script.sh

---script.sh ---
#!/bin/sh

WK=`date +%W`
ON_WK=`expr $WK % 2`

if [ $ON_WK = 1 ]; then
  < your job here .... > 
fi
----------------
Every Monday, the script.sh runs, but script.sh examines the date and continues only when it's running on an odd or even
week.

Wesly
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now