Sponsored Content
Top Forums UNIX for Advanced & Expert Users Use cron to run job every other week Post 302460747 by jim mcnamara on Thursday 7th of October 2010 12:59:54 PM
Old 10-07-2010
That won't work - if it ran say on the 30th it will also run on the week of 1 - 7.

And the answer is no - just using the crontab * * * * * entries there is no reliable way.
You need to alter the command structure - the part calling your script

Assuming your system supports
Code:
date +%s

Because every second Friday is an odd number of days since Thursday, Jan 1, 1970 and
every first Friday is an even number; plus there are 86400 seconds in a day:

when you execute this every friday it will test the day and run
Code:
# "first" friday  -- and note # generally does work in crontab files as a comment
0 8 ** 6  [ $((  $(( $(date +%s ) / 86400  )) % 2 )) -eq 0 ] && /path/to/myjob
#  "second" friday
0 8 ** 6  [ $((  $(( $(date +%s ) / 86400  )) % 2 )) -eq 1 ] && /path/to/myjob

 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Run cron job problem

I have the below crontab job that it will run at every 7:00am - 10:00am , it work fine , now if I want to skip to run the crontab job at a specific time , eg. I want the script not to run at next Monday 8:00am ( only skip this time , other time is normal ) , how can I make it ? is it possible ?... (3 Replies)
Discussion started by: ust
3 Replies

2. UNIX for Dummies Questions & Answers

setting up cron job for month end week report

Hi all, Needs your help in scheduling a cron job for the below mentioned requirement. Just let me know if anybody has a similar job running as mentioned below: Month end reports - Report of all items created in a parent table that were created during the week. Presently this report runs... (3 Replies)
Discussion started by: Bhups
3 Replies

3. UNIX for Dummies Questions & Answers

cron job to run php file

Hello, I have searched and searched google to do this and i want my websever to be able to run a php file everyday automatically. How do I go about doing this? Php is installed as an apache module not CGI. Thank you! (3 Replies)
Discussion started by: christo16
3 Replies

4. Shell Programming and Scripting

Does not run via cron job

I have a perl script, when I ran manually it works perfect. I check the permissions which are fine. How can I find out why it is not running? how can I setup a log to check. I am running it on solaris 9. It compares multiple files, SCP and then send out an e-mail. As I said when I ran it... (2 Replies)
Discussion started by: amir07
2 Replies

5. UNIX for Advanced & Expert Users

Need help with a script run by a cron job.

Hi, new to this forum and not sure if this is the right place to post. I'm new to cron jobs and scripts, and I need some help with a script to be used with a cron job. I already have a bot set up at a certain website address and need a script that the cron job will load every day that tells it to... (1 Reply)
Discussion started by: klawless
1 Replies

6. Shell Programming and Scripting

how do I run bash script using cron job

How do I run bash script using a cron job? I have tried to just write the path of the script, but that didn't work. (1 Reply)
Discussion started by: locoroco
1 Replies

7. Shell Programming and Scripting

Cron job - Need to run Cron every quarter at particular time

Hi, 1) If some job supposed to run on 1st of every month at 7 AM In cron job when we have a blackout on the 1st ( i.e when 1st falls on a sunday ) how can we make the job run the next business day? 2) How can we run a job on 25th of every quarter 7 AM(jan,apr,jul,oct) And if 25th... (5 Replies)
Discussion started by: System Admin 77
5 Replies

8. Shell Programming and Scripting

Cron Job to Run for 30 minutes

Hello Gurus, I have a requirement to run a job from cron only for 30 minutes duration daily twice at 8.35 am and 20.35 pm Can you please suggest how to schedule the job? Thanks- Pokhraj (5 Replies)
Discussion started by: pokhraj_d
5 Replies

9. Shell Programming and Scripting

Cron Job to Run every 2 minutes

Hello Gurus, I want to schedule a cron job which will run every 2 minutes starts at 11:25 AM and 3:25 AM daily. Can you please suggest as how to schedule the job. Thanks- Pokhraj Das (2 Replies)
Discussion started by: pokhraj_d
2 Replies

10. Shell Programming and Scripting

Cron job cannot run the command

Hi, I created this cron job for asterisk to send sms daily to a number #!/bin/sh #custom mod - send sms once a day, at 07:00. CRON_PATH="/etc/asterisk/gw/crontabs_root"; if ! grep 'gsm send sms' $CRON_PATH > /dev/null 2>&1 ;then echo "* 7 * * * asterisk -rx 'gsm send sms 1 7666... (4 Replies)
Discussion started by: jazzyzha
4 Replies
power_onoff(1M) 														   power_onoff(1M)

NAME
power_onoff - timed, automatic system power on, and power off SYNOPSIS
time [date] ] time_designation] DESCRIPTION
instructs the UPS monitor to shut down the system, and optionally informs the monitor when to power on the system again. The UPS monitor in turn instructs the uninterruptible power source (UPS) when to turn the power off and on. The UPS monitor then proceeds to shut down the system. The time to restart the system (power on) is specified with command-line arguments. Some UPS units limit the time that can elapse between the time the power is turned off and the time it is turned back on. Please see your UPS documentation for information about limitations. requires a UPS that is supported by the UPS monitor (see ups_mond(1M)). Command Line Arguments The command has two forms, and recognizes the following arguments: No power on. Causes the system to be shutdown and not be powered back on. time Can be specified as one, two, or four digits. One- and two-digit numbers represent hours; four digits represent hours and min- utes. time can also be specified as two numbers separated by a colon single quote the letter "h" a period or comma A suffix or can be appended. Otherwise a 24-hour clock time is understood. For example, and are read as 15 minutes after 8 in the morn- ing. The suffixes and can be used to indicate Coordinated Universal Time. The special names and are also recognized. date Can be specified as either a day of the week (fully spelled out or abbreviated) or a date consisting of a day, a month, and optionally a year. The day and year fields must be numeric, and the month can be fully spelled out, abbreviated, or numeric. These three fields can be in any order, and be separated by punctuation marks such as slash hyphen period or comma The years 00-68 would be interpreted as 2000-2068 and 69-99 would be 1969-1999. Two special ``days'', and are also recognized. If no date is given, is assumed if the given time is greater than the current time; is assumed if it is less. If the given month is less than the current month (and no year is given), next year is assumed. or If followed by a time_designation of or lets the user startup the system when the specified time_designation has elapsed. A numerical operator, enables the user to schedule the startup several hours, days, weeks, months, or years in advance (see EXAMPLES). Using the argument is equivalent to using an increment of Both plural and singular forms of time_designation are accepted. EXTERNAL INFLUENCES
International Code Set Support Single- and multi-byte character code sets are supported. RETURN VALUE
Exit code 0 is returned upon successful completion, otherwise non 0 is returned. DIAGNOSTICS
issues diagnostic messages when it encounters syntax errors and out-of-range times. EXAMPLES
To startup the system at 5:00 am next Tuesday, use To startup the system at 5:30 am tomorrow, use To make your system startup each weekday at 7:30 am and shutdown at 5:30 pm each week day, use to execute the first entry on Monday through Thursday and the second entry on Friday (see crontab(1)). To startup the system at 8:15 on January 24, use To startup the system at 5:15 on January 24, use To startup the system at 9:30 tomorrow, use To startup the system 24 hours from now, use To shutdown the system and not start it up, use WARNINGS
Jobs can be submitted up to 2037. If jobs were submitted any later than 2037, an error message will display "BAD DATE". Some UPS units limit the time that can elapse between the time the power is turned off and the time it is turned back on. Please see your UPS documentation for information about limitations. If the date argument begins with a number and the time argument is also numeric (and without suffix), the time argument should be a four- digit number that can be correctly interpreted as hours and minutes. Do not use both and within a single command; only the first operator is accepted and the trailing operator is ignored. No warning or error is produced. The power cord must be disconnected before servicing the unit. AUTHOR
was developed by HP. FILES
fifo for communicating with ups_mond. SEE ALSO
at(1), cron(1M), crontab(1), queuedefs(4), proto(4), kill(1), sam(1M), ups_mond(1M). power_onoff(1M)
All times are GMT -4. The time now is 09:22 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy