LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 08-30-2016, 05:33 PM   #1
tushar.jadhav29
LQ Newbie
 
Registered: Apr 2016
Posts: 11
Blog Entries: 1

Rep: Reputation: Disabled
crontab query


hi all,

I am little confuse to write the cron job rule.

How can i write the job, should run alternative day midn8 at 12:00

Every month in last date cron job has to run ( where i am observe
month end may come 31, 30,28.so how we can write the rule)

please suggest.

thanks
 
Old 08-30-2016, 06:10 PM   #2
timl
Member
 
Registered: Jan 2009
Location: Sydney, Australia
Distribution: Fedora,CentOS
Posts: 750

Rep: Reputation: 156Reputation: 156
Hi,

firstly a couple of tips - please don't use text speak when posting and don't post a supplementary/unrelated question after the first.

Regarding cron: first port of call is to hop into a terminal and type:

Quote:
man cron
or

Quote:
man crontab
If those resources don't answer your questions it is best to try your favourite search engine and enter something like:

Quote:
parameters to run cron on last day of every month
That should throw up plenty of options you can try out

Cheers
 
1 members found this post helpful.
Old 08-30-2016, 06:18 PM   #3
tushar.jadhav29
LQ Newbie
 
Registered: Apr 2016
Posts: 11

Original Poster
Blog Entries: 1

Rep: Reputation: Disabled
Thanks timl,
 
Old 08-31-2016, 03:25 AM   #4
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,475

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
Quote:
Originally Posted by tushar.jadhav29 View Post
Every month in last date cron job has to run ( where i am observe
month end may come 31, 30,28.so how we can write the rule)
You can't do this kind of rule with cron.

What you can do is schedule your job to run on days 28,29,30,31 and use this test as part of the jobs bash script:

Code:
if [ $(date +%d -d "tomorrow") -ne 1 ] ; then exit 128 ;fi
This will cause your script to exit with errorlevel 128 if it's not the last day of the month or continue if it is the last day of the month.
 
2 members found this post helpful.
Old 09-01-2016, 09:47 PM   #5
tushar.jadhav29
LQ Newbie
 
Registered: Apr 2016
Posts: 11

Original Poster
Blog Entries: 1

Rep: Reputation: Disabled
thanks Ten,


issue have been resolved.
 
  


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] crontab does not reread the crontab file upon modification of the latter. stf92 Slackware 4 08-01-2015 06:12 PM
crontab - root user query pappin Linux - Software 2 03-05-2014 03:28 AM
[SOLVED] Problem with crontab:: command not executed properly via crontab Ankush Seth Linux - Newbie 11 11-11-2013 06:25 AM
query over crontab rohit khare Linux - Server 1 07-29-2010 02:55 AM
CRONTAB Query Keith Birch Linux - General 1 06-14-2005 08:13 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 06:25 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