Cron job ,every other monday

hello
i would like to schedule a cron job every other monday
-- OS info
[oracle@dev3 ~]$ uname -a
Linux dev3.pcst3.net 2.6.18-194.17.1.0.1.el5 #1 SMP Wed Sep 29 15:57:39 EDT 2010 x86_64 x86_64 x86_64 GNU/Linuxhere is what i have in for cron job , yes this shows every monday but i am looking for every other monday,it ran today(03/26),next runs should be 04/09 and 04/23 ....
# Bi-weekly report
30 11 * * 1 /u01/scripts/monday_query.sh > /u01/scripts/monday_query.log 2>&1here is what we have in monday_query.sh
#!/bin/ksh
# set -xv
. dbbash_profile
export ut=/u01/scripts/ut
export pass=`grep -i ls011 $ut/pwdfile | awk -F":" '{ print $2 }'`
sqlplus  ls011/${pass} < /u01/scripts/monday_query.shany help is much appreciated to make this run every other monday
Please help

From the cron man page: http://unixhelp.ed.ac.uk/CGI/man-cgi?crontab+5
"Step values can be used in conjunction with ranges. Following a range
with ``/<number>'' specifies skips of the number's value through the
range. For example, ``0-23/2'' can be used in the hours field to spec-
ify command execution every other hour (the alternative in the V7 stan-
dard is ``0,2,4,6,8,10,12,14,16,18,20,22''). Steps are also permitted
after an asterisk, so if you want to say ``every two hours'', just use
``*/2''."
Or, create a flag file with 'touch ran_cron_job_last_monday' after a Monday that you ran the script.
Then throw a condition into your script to check for the file. If the file exists, remove it. If the file doesn't exist, then run your script and when finished, create the file again.
For example:
#! /bin/ksh
if [ -e ran_cron_job_last_monday ] ; then
rm -f ran_cron_job_last_monday
else
touch ran_cron_job_last_monday
exit 0
fi
... do here what your script is supposed to do ....
exit 0

Similar Messages

  • Run a cron job every minute

    Hi,
    I would like to run a cron job every minute.
    I can find cron.hourly, cron.daily, cron.weekly, cron.monthly in my /etc, but no cron.minutly.
    Can I get it? What should I do?
    Thanks!
    Nathan

    run
    crontab -e
    . this opens an editor. therein you type :
    #min hour day month weekday command
    */1 * * * * <your command>
    dw was faster
    Last edited by DonVla (2008-11-17 16:56:42)

  • Cron job every 4th Saturday

    I have a 'ditto' command that I'd like to run every 4th Saturday.
    Can anyone advise how I should set crontab?

    In short, you can't do this in one step.
    You might think you can do something like
    0 0 22-28 * 6 /path/to/ditto blah blah blah
    which most people would interpret as run at midnight on every day between the 22nd and 28th of the month that happens to be a Saturday, but cron actually interprets this as 'run every day between 22-28 and also on Saturdays' which isn't what you want.
    The easiest solution is to write a wrapper for your ditto command. Have your crontab call your script on one of the parameters (e.g. every day between the 22nd and the 28th) and the first thing your script does is check if the day is the other condition (e.g. Saturday). If it isn't, it gracefully exits.
    This wrapper script could be as simple as:
    #!/bin/sh
    DAY="`date +%u`"
    if [ "${DAY}" = "6" ] ; then
       echo "Saturday - time to backup"
       # ditto command goes here
    else
       echo "Not Saturday - do nothing""
    fi

  • Reg Cron Jobs

    hi,
    I need to run a cron job every alternate wednesdays...in a year
    Any suggestions????
    Thnx,
    Enz

    Method 1: Run a cron job every wednesday. Run your job if `date +%U` is even.
    problems: Some years will have 53 wednesdays, so eventually you'll run your job on consecutive weeks.
    Method 2: Run a cron job every wednesday. Set a file as a sentinel. If clear, set it and run your job. If set, clear it and dont' run the job.
    problems: If the cron job fails to run, your "alternate week" might get out of sync. Someone might screw up the sentinel file.
    Pick one based on your needs
    Darren

  • Cron Job and PHP

    I am having problems running a cron job every one minute that calls a PHP script. Please see below:
    1 * * * * /usr/bin/php /Library/WebServer/Documents/secureohs/publichtml/reassignMSCcomptrack.php
    If I execute the command above, it runs just fine.
    Thank you in advance.

    I guess it would :)
    btw, how did this piece miss from the contents pasted by the OP ?
    The doc has given all details of CRON and missed where to see the logfiles. :)
    ****Added****
    I tried man crontab in windows, i dont see it.i overlook most of the things, i would have done the same ;)
    Edited by: Bobcatalog on Oct 23, 2008 9:40 AM

  • Cron Job in Statistics

    Hi all,
    Is oracle recommend any cron job in secure enterprise search? I want to send a STATISTICS to email to administrator email address. Is any standard cron job is there?
    Thanks!

    Internally, we do this using Enterprise Manager.
    Have a look at the paper here:
    http://www.oracle.com/technology/products/oses/pdf/ses_em_whitepaper.doc
    Even if you don't wish to use EM, this will probably give you some useful info for creating cron jobs.

  • Cron job help- Need to run the Autobuddy command every night...

    I have not written anything in the form of a Unix script for YEARS and YEARS. Our XServe was built in Advanced mode, currently running 10.5.4 Server. On this box, we are running Wiki and iChat. Since we built this box as an Advanced box the "Autobuddy" option was not available.
    I have since enabled it at the command line, but I am told by Apple that there still needs to be a command run after every time a user logs in if you want others to Autobuddy. That command is this:
    "sudo /usr/bin/jabber_autobuddy -m"
    Now I think this would be pretty easy to setup as an automatic cron script, but like I said, I have not written something like this in forever. Not to mention, I am not 100% sure what needs to happen since running the script with an sudo command will prompt for the root password.
    I was wondering if anyone would be able to help me write the script up, and give me some instructions on how to install it. I just want it run everyday, midnight is fine, I don't really care. All I know is that we have a dept of 150 people, and it grows and shrinks all the time. They can deal with a new user not being seen for 24-48 hours, I just want to get this automated.
    Any helps would be GREATLY appreciated!
    Thanks
    Tom

    If you want to keep it simple try [CronniX|http://www.abstracture.de/projects-en/cronnix] a graphical tool for setting up CRON jobs on OSX. Whilst I have not actually done an autobuuddy in this way, I cannot see any reason why it will not run as a Cron Job.
    The proper way ideally would be to use the launchd service.
    Something like this should work:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
    <key>Label</key>
    <string>org.jabber.dailyautobuddy</string>
    <key>ProgramArguments</key>
    <array>
    <string>/usr/bin/jabber_autobuddy</string>
    <string>-m</string>
    </array>
    <key>LowPriorityIO</key>
    <true/>
    <key><UserName></key>
    <string>admin</string>
    <key>StartCalendarInterval</key>
    <dict>
    <key>Hour</key>
    <integer>0</integer>
    <key>Minute</key>
    <integer>05</integer>
    </dict>
    </dict>
    </plist>
    (not sure why, but tabs are not showing up, making this hard to read)
    Message was edited by: Tim Harris

  • [SOLVED] Cron Job that starts every 30 minutes from boot

    I wish to have a cron job that runs a script every 30 minutes from boot, without any users logging in.
    I know about crontab -e, but I think that would I only run once i'm logged in. I've also heard about @reboot, but that would only run the script once.
    RabbidRabbit
    Last edited by rabbidrabbit (2012-01-31 20:14:13)

    Cron jobs will run whenever the system is up, regardless of whether or not anyone is logged in.
    I don't remember the syntax, but I know that at least some cron implementations have a way to run a job every 30 minutes, starting for the first time 30 minutes after reboot.
    EDIT: I just checked the syntax for fcron, which is what I use, and it seems like doing @ 30 your/command/here will make it run every 30 minutes of uptime.
    Last edited by kyla (2012-01-31 00:17:30)

  • Using cron-job to call the PL/SQL procedure for every 5 min

    Hi All,
    i wrote one procedure. using cron-job to call this PL/SQL procedure for every 5 min. i don't have any idea about cron job & what is thescript file formate .where can i place that script file. what are the details we placed in that script

    Really appreciate you. I like this approach .
    please give me advice for the below thing
    job_action =>an i give my procedure name under this?
    BEGIN
    -- Job defined entirely by the CREATE JOB procedure.
    DBMS_SCHEDULER.create_job (
    job_name => 'Job_schedule_update',
    job_type => 'PLSQL_BLOCK',
    job_action => 'BEGIN Schedule_update; END;',
    start_date => SYSTIMESTAMP,
    repeat_interval => 'FREQ=HOURLY;BYMINUTE=5',
    end_date => NULL,
    enabled => TRUE,
    comments => 'Job defined entirely by the CREATE JOB procedure.');
    END;

  • Cron job to start machine.

    Is there a way to get the machine to start, open iTunes and start playing a song at a specified time using a cron job?
    MacBook Pro 15.4" - Intel Core Duo 2.0   Mac OS X (10.4.6)   2GB RAM

    I have my computer do exactly what you want yours to do, except I don't use a cron job. In case you don't actually need to use cron, I'll tell how I get it to happen.
    As mentioned by Federico_82, I use the Energy Saver preferences in System Preferences. There is an "Schedule..." button in the lower right corner that will allow you set the startup and/or shutdown times for the computer. It's not very detailed, but it suits my purposes for waking up Monday through Friday.
    I also have the computer automatically log me in using the Login Options in Accounts preferences in System Preferences.
    Finally, I've set alarms in iCal and chose "Open file" in the alarm section of the Info drawer. You can select a song file (or anything really) to be opened and the song will be played with iTunes since songs should automatically open with iTunes.
    I've also set the final option in the alarm section to perform this 5 minutes before the time I set for the event, with the event time being the same time as the computer startup. This is okay because it will perform an alarm that was suppose to happen even if it couldn't do it earlier, for example because the computer was off. So you don't have to worry about timing it perfectly. Just set the alarm time to the same as the startup time for the computer or earlier if you want it to happen immediately upon startup, then the alarm will go off immediately after computer turns on and logs you in.
    Also keep in mind you can set the event to repeat at various intervals in iCal, such as Monday through Friday or various discontinuous days of the week every week, and so on. Very customizable.
    Personally, I use an Automator app to start playing a playlist in iTunes, and to set the iTunes volume to an appropriate level to wake up with just in case I've change the volume the last time I used iTunes. In this way, I can simply change the song in the playlist in iTunes without having change the alarm event in iCal. This helps because then I can copy/paste the alarm anywhere I want and don't have to worry about finding another song file if I want to change the song. Instead, I simply find the song I want in iTunes and put it in the playlist, along with any other songs I want have played.
    If you do it with an Automator workflow, simply save the workflow as an iCal Alarm with "Save As Plug-in...". It'll automatically save in your ~/Library/Workflows/Applications/iCal folder, without you having to figure that out. Oh, and it doesn't hurt to test the workflow to make sure it plays your playlist (or whatever you have it do) before saving it as an iCal Alarm. Though, you can re-edit later if you want.
    Once you've saved your workflow as an iCal Alarm, it'll show up in list of files to open in the alarm section for the event. So, after you've chosen "Open file" in that section, the default for the file will be "iCal", but you'll also be able to choose any iCal alarms you've saved in Automator or any other file (such as a document or a song).
    Just as a bit of trivia, a plug-in you save in Automator is actually the same thing as saving your workflow as an application. The only difference is that the app is saved to a specific location so the Finder, or iCal, or Image Capture, etc., can find it. So, you don't have to know where to save it, Automator does that for you, but I told you where it is anyways (though you could use Spotlight) so you can get to it to edit it again if you want. Just drag and drop the app onto Automator or open it from within Automator to edit it again.
    I hope that helps. Though it might sound kind of complicated at first, I think this way is much easier than dealing with a crontab and trying to synchronize it with startup and so on. You'll also find this way very customizable with the various options for iCal alarms and the many possibilities with Automator (if you choose to use a workflow instead of simply a song file).

  • How to Run cron Jobs(Schduled jobs)

    HI all,
    I am runnig one webapplication in resin.In resin web.xml run at tag like below
    <run-at>01:50,03:50</run-at>This tag is used for runnig some periodic jobs.I want to cleanup the database every day at above mentiond timings.But in tomcat htere is no option like that.Is there any way to develope cron jobs please help me.
    Thanks in advance

    Do you have other tasks in cron?
    I will assume not. You have to make sure you have permissions to do cronjobs.
    If so, then just type crontab -e
    From here you can use the following guideline to make your cronjob. Also source your .profile or whatever in your shell script.
    Minute = Minute of the hour, 00 to 59. * Will indicate every minute (details later)
    Hour = Hour of the day in 24-hour format, 00 to 23. * Will indicate every hour (details later)
    Day = Day of the month, 1 to 31. * Will indicate every day (details later)
    Month = Month of the year, 1 to 12. * Will indicate every month (details later)
    Day = Day of the week, 3 chars - sun, mon, tue, or numeric (0=sun, 1=mon etc).... * Will indicate every day (details later)
    Task = The command you want to execute
    So if I had a shell script called runme.sh and in it it called my .profile (which sets my oracle_home and path etc) and it also called sqlplus and ran my script this is how I would set it up. Let's assume we want it to run 10 minutes after midnight every night.
    10 0 * * * runme.sh
    Let's assume you want a log, then it can look like this.
    10 0 * * * runme.sh 1> path/filename.log 2> path/errorlog.err
    If you wanted to just run it from Monday through Friday, then do this.
    10 0 * * 1,2,3,4,5 runme.sh
    Hope this helps.

  • Cron job not running - script uses rsync, ssh (with id_rsa)

    Does anyone know how to get cron to run a rsync/ssh script which uses id_rsa for passwordless logins?
    I have a backup script I have slaved for months over that works wonderfully when running it from the command line.
    It uses rsync and connects with SSH (passwordless using ssh keys). I have setup id_rsa and id_rsa.pub for passwordless logins (this is my user account, and connects using root@ to the server)
    As stated all works find when run from the command line. But when I setup a cron job to run this file (exact same line I run from the command line) it does not execute. Actually, it does run, as I have an email notifiction which sends to me. It is just the rsync/ssh part that does not run.
    I have spent days and days trying to figure it out. No error messages occur, nothing.  Took me a while to find out cron is emailing the user account on Lion the messages (not to a proper email address).
    The error shows a permission denied, which I believe to be the cron user cannot use the id_rsa/ssh connection.
    Cron is running the script as my user, the same I use on the command line. I even tried copying the id_rsa to the root user .ssh folder in case cron is running as root but that does not work either.
    So does anyone know how to get cron to run this rsync/ssh script which used id_rsa for passwordless logins?
    Thanks a lot

    YES! Got it working, finally!
    So the issue is indeed cron/launchd not being able to access the ssh-agent which holds the key.
    So this is the solution...
    Download keychain for Mac:
    http://www.funtoo.org/wiki/Keychain
    Then once its installed and configured, the script to run needs this added to the top:
    eval `keychain --noask --eval id_rsa` || exit 1
    Note I am using id_rsa whereas keychains instructions refer to id_dsa so I just changed it and it works OK.
    When the script runs the first time it asks for the key password. Then it works from then on.
    What I do not know yet is will I need to re-enter the password when I logoff/logon again. That will cause an issue as I auto restart the Mac every day which means if I am off for a few days backup will stop (can you see the madness in this issue!).

  • How to take the cron job log in HP UX?

    Hi,
    How to take the cron job log in HP UX
    I need to run a backup and other stuff everyday. How do I check and start cron service under HP-UX UNIX operating system? How do I write cron jobs?
    A. Cron service is required to run jobs and tasks such as backup.
    You must login as the root to run following commands. Each user that is using the cron service must have a cron configuration file in the /var/spool/cron/crontab directory. Also users are permitted if their name appeared in /var/adm/cron/cron.allow file
    Task: Find out if cron is running under HP-UX
    Type the following command at a shell prompt
    # ps -ef | grep cron
    Open /etc/rc.config.d/cron file
    vi /etc/rc.config.d/cron
    Set control variable to 1 to enable cron: CRON=1
    Set control variable to 0 to disable: CRON=0
    Close and save the file. To start or stop cron you can type the following command:
    # /sbin/init.d/cron start <-- start cron
    # /sbin/init.d/cron stop <-- stop cron
    Task: HP-UX Start cron service
    If cron is not running, simply type:
    # cron
    Task: Edit / create cron jobs
    Type the following command to submit a cron job:
    # crontab -e
    List your cron file:
    # crontab -l
    Backup all your cron jobs:
    # crontab -l > ~/backup.cron.jobs
    Remove ALL cron job:
    # crontab -r
    Task: Crontab file format
    Cron file format is as follows:
    MIN HOUR DATE MONTH DAY /PATH/TO/COMMAND
    0-59 0-23 1-31 1-12 0-6 /root/scripts/backup2tape.shEasy to remember crontab file format:
    * * * * * command to be executed
    | | | | |
    | | | | ----- Day of week (0 - 7) (Sunday=0 or 7)
    | | | ------- Month (1 - 12)
    | | --------- Day of month (1 - 31)
    | ----------- Hour (0 - 23)
    ------------- Minute (0 - 59)To run /root/script/backup at 23:00, every day, enter:
    # crontab -e
    Append following
    0 23 * * * /root/script/backupRun foo job very weekday (MON-Fri) at 6am, enter:
    0 6 * * 1-5 /root/script/backupFor more information refer to cron and crontab man pages.
    Subscribe to our free e-mail newsletter or RSS feed to get all updates. You can Email this page to a friend.
    Related Other Helpful FAQs:
    What is Cron?
    Linux Start and stop the cron or crond service
    Run crontab Every 10 Minutes
    Linux / UNIX Setup and run php script as a cron job
    Stop Ubuntu / Debian Linux From Deleting /tmp Files on Boot
    Discussion on This FAQDavid Says:
    January 15th, 2008 at 12:21 am
    You might note that all files normally found in /etc/init.d, /etc/rc*.d, and others are all in /sbin in HP-UX 10.20 and up.
    Note too that your formatting is off in the description of the /etc/rc.config.d/cron file. Also, if you run /usr/bin/cron instead of /sbin/init.d/cron start, the /etc/rc.config.d/cron file is not used.
    Regards,
    Satya

    I guess it would :)
    btw, how did this piece miss from the contents pasted by the OP ?
    The doc has given all details of CRON and missed where to see the logfiles. :)
    ****Added****
    I tried man crontab in windows, i dont see it.i overlook most of the things, i would have done the same ;)
    Edited by: Bobcatalog on Oct 23, 2008 9:40 AM

  • Need help with a cron job

    What I want to do is run an Applescript every 6 hours and 1 minute. If the computer is asleep when the job comes due, I want it to execute the script and reset the counter. Can crontab do this? If so, how to set it up?

    Gnarlodious wrote:
    Then skip it, I can see there is no easy way.
    I don't think it's that hard, though. Just a bit tricky. I was just a bit confused on what exactly you wanted.
    I could write a stay-open Applescript application, but I wanted to avoid cluttering up the Dock just to run a command every 6 hours.
    Nah, I wouldn't want that either.
    If I were doing something like this and I wanted it to work like this:
    1. Run every six hours, at 6 AM, noon, 6 PM, and midnight.
    2. Run after waking up if the computer has been asleep and missed any of the times in between, say if you let the computer sleep thru the 6 AM job.
    I'd do this:
    1. Call the AppleScript periodically from a cron job. How often would be dependent on how tight you want the times to be to when you wake up.
    2. Have the AppleScript save a text file somewhere with the time when it runs. That way, if your computer is asleep at 6 AM, the script could use this to decide if it missed running while it was asleep.
    3. Have your script check this time and if it's over 6 hours, let the script do its thing. If not, then just exit, to try all this again the next time cron runs it.
    Here's kind of a pseudo-code way of describing it:
    check if it's 6:01, 12:01, 18:01, 00:01
    if yes:
    do your AppleScript business
    save the current time in a file
    exit
    if it's not one of those times:
    check if it's been over 6 hours since the AppleScript did its business
    if yes:
    do the AppleScript business
    save the current time in a file
    exit
    if no:
    exit
    Then you could do two cron jobs:
    1 */6 * * * /path/to/applescript
    */5 * * * * /path/to/applescript
    The first one would run at your appointed times. The second would just run every 5 minutes to catch those times when the computer was asleep. The "5" could also be "10" for every ten minutes. Or whatever you decide you'd like.
    I'd show you an AppleScript, but I'm really not so good at that. If a Perl script would help, I could whip one up pretty quickly, I think.
    charlie

  • Is it possible to have a Cron job in CPO to check the running status of a workflow

    Is it possible to have a Cron job in CPO to check every hour to see if a particular workflow is running, if not trigger it by creating a alert, if yes- autokill

    Hi Warren,
    We don't want our process to expire and also not to execute twice at once. We have a provisioning wrapper workflow which is triggered one time by an alert and it runs endlessly by creating an alert at the end of each instance triggering another instance of the same unless CPO hangs or goes to stand by mode. Since we belong to service team, we don't have any kind of access to CPO DB or logs, so that possibility is ruled out. Just checking for alternatives. 

Maybe you are looking for