LinuxQuestions.org
Visit Jeremy's Blog.
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 01-19-2011, 04:06 AM   #16
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978

Quote:
Originally Posted by smilemukul View Post
Can any one tell me what the below expression means while creating a script as,

[`date +%a` = Sun ]
This tests if the output of the command date +%a is equal to Sun. Backticks are the syntax for command substitution, as well as the new syntax for bash/ksh $(command). Pay attention to spaces: there must be a space after the opening bracket and a space before the closing one, e.g.
Code:
[ $(date +%a) = Sun ]
and yes.. this is a way to test if the current day is Sunday.
Quote:
Originally Posted by smilemukul View Post
Also need to confirm whether below command is correct for running a cron job for 3rd Sunday as,

0 0 15-21 * * [`date +%a` = Sun ] && /path/to/command

Thanks
It should work (provided the syntax is slightly corrected, as explained above). This crontab runs at 00:00 of every day between 15th and 21st of every month. It checks if it's Sunday and execute /path/to/command accordingly.
 
1 members found this post helpful.
Old 01-20-2011, 10:09 AM   #17
smilemukul
Member
 
Registered: Jun 2009
Distribution: Redhat,CentOS,Ubuntu,Puppet
Posts: 292

Original Poster
Rep: Reputation: 34
Thanks, appreciated for the response & verifing the syntax.

Thanks
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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] Scheduling a CRON job to run on the first Sunday of the month New2Linux2 Linux - Software 10 11-08-2016 12:25 PM
adding a perl script to cron.daily / cron.d to setup a cron job CrontabNewBIE Linux - Software 6 01-14-2008 08:16 AM
Scheduling Cron Job chnlinux Linux - Newbie 5 10-16-2007 04:51 AM
LXer: Linux tip: Job scheduling with cron and at LXer Syndicated Linux News 0 07-21-2007 03:16 AM
scheduling monthly job in cron from debian sarge 3.1 sridhar11 Debian 2 10-28-2005 09:03 AM

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

All times are GMT -5. The time now is 12:22 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration