LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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 11-18-2016, 07:17 AM   #1
ghpradeep
Member
 
Registered: Mar 2011
Posts: 32

Rep: Reputation: 0
Cronjob for biweekly


Hello Team,

I need cronjob syntax to schedule job for every 2 week(biweekly).
for example, suppose i executed job today(18 Nov) then next job should execute on 2 Dec on 10 AM.

I tried with below syntax but does not work out.
note: running on ubuntu system.

* 10 * * 5/2
* 10 7-14,21-28 * 5

Please help me here.

Last edited by ghpradeep; 11-18-2016 at 07:19 AM.
 
Old 11-18-2016, 07:28 AM   #2
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
i think you will need to cron it weekly and handle the bi-weekly logic in the program being run.

i would have it touch a file when it ends and create an if statement to check for the existence of said file and if it does exist then delete it and end; else continue.
 
Old 11-18-2016, 07:35 AM   #3
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 98
I dont have a Linux session to hand at present but I would expect the 1st example to be invalid

Both are requesting to run every minute between 10:00 and 10:59 which I don't think is what you want

Fields are:

Minutes
Hours
Dayofmonth
Months
Dayofweek

Suggesting your 2nd option is closer to what you are asking for
 
Old 11-18-2016, 07:56 AM   #4
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
using google and your question "Cronjob for biweekly" I found these,

http://serverfault.com/questions/404...weekly-cronjob

http://stackoverflow.com/questions/1...y-twice-a-week

http://www.unix.com/unix-for-advance...ough-cron.html
 
1 members found this post helpful.
Old 11-18-2016, 12:35 PM   #5
crazy-yiuf
Member
 
Registered: Nov 2015
Distribution: Debian Sid
Posts: 119

Rep: Reputation: 51
It would be overkill if this is all you need to do. But if you find yourself doing this sort of thing a lot, and it's appropriate for your environment, you might be interested in remind. It has an entire language built for scheduling things, and you can view reminders as a calendar using wyrd. It can also execute arbitrary scripts instead of reminding you of things, though I'm not sure I'd give it root privileges. Here's an example from the man page:

For example, suppose you get paid every second Wednesday, and your last payday was Wednesday,28 October, 1992. You can use:
REM 28 Oct 1992 *14 MSG Payday

Also, anacron and (I would assume) systemd timers could be used for this.

Last edited by crazy-yiuf; 11-18-2016 at 12:44 PM.
 
  


Reply



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
[SOLVED] Cronjob shaik_rafi2009 Linux - Newbie 8 01-07-2013 08:44 AM
LXer: Biweekly report #2 : notification integration in the lock screen LXer Syndicated Linux News 0 06-10-2012 03:50 PM
Need suggestion on biweekly backup job cojo Linux - Software 12 11-06-2006 08:17 AM
cronjob help meeh Linux - General 1 03-26-2004 11:41 AM
Cronjob engnet Linux - Networking 6 03-03-2004 09:21 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:56 AM.

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
Open Source Consulting | Domain Registration