Cron scheduler issue


 
Thread Tools Search this Thread
Operating Systems Linux Red Hat Cron scheduler issue
# 1  
Old 11-08-2014
Cron scheduler issue

I am trying to schedule a script in Linux to between 8th and the 31st of each month on Sundays @ 6:50 only and i scheduled it as follows:
Code:
50 6 8-31 * 0 ksh /home/cpac/SPID_Files/GetFiles.ksh

Which did it run on the 8th on Saturday instead of only Sundays !!!

Last edited by Scott; 11-08-2014 at 05:48 AM.. Reason: Code tags, please...
# 2  
Old 11-08-2014
That isn't the way cron works. The crontab entry:
Code:
50 6 8-31 * 0 ksh /home/cpac/SPID_Files/GetFiles.ksh

specfies that the command ksh /home/cpac/SPID_Files/GetFiles.ksh is to be run at 06:50 on every day that is a Sunday and on every day with a day of month that is is from 8 through 31 inclusive. So, in November 2014, it would run on the 2nd and the 8th through the 30th.
This User Gave Thanks to Don Cragun For This Post:
# 3  
Old 11-08-2014
Don's very clear message is that both day of the week and day of the month are both going to act independently to run the job at 6:50 AM

You have to check either the day of the week or the day of the month outside of the * * * * section of the crontab line, and drop that check in the section. Both together do not fly the way you want.

try:
set the Sunday ( 0 ) to a * then add logic to see if it is Sunday:
Code:
50 6 8-31 * *  [ `date +%w` -eq 0 ] && ksh /home/cpac/SPID_Files/GetFiles.ksh

This User Gave Thanks to jim mcnamara For This Post:
# 4  
Old 11-09-2014
I also figured it out as follows:
50 6 8-31 * * [ "$(date '+\%a')" == "Sun" ] && /home/cpac/scripts/CommandLine/GetFiles.ksh

Thank you Jim. Your suggestion is great too.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Program not running from the cron scheduler

Good Afternoon, I have a sh script that the admin added to the cron schedule. It runs fine when I run it manually...but not when scheduled. I added the path that is found for my user to the script. Still no luck. Any ideas what I should look at? Thanks Marty (8 Replies)
Discussion started by: MSpeare
8 Replies

2. UNIX for Advanced & Expert Users

OS Watcher not running with cron scheduler

Hi team, O.S : Oracle Linux Issue : I am facing issue when running OS watcher script from cron scheduler. But when i run the same command manually, its getting executed. Note : I have to press " Enter " button to get out of the blank screen when I execute the script manually. Below is... (1 Reply)
Discussion started by: madhuraju
1 Replies

3. Shell Programming and Scripting

Help needed regarding cron job scheduler with CyberArk Password security

Hi All, I have a script which will restart some web server and bring it up again. For that I need to retrieve 3 password from CyberArk (Cyber-Ark - Wikipedia, the free encyclopedia) vault. My question is: Is this possible to schedule the script through cron and automatic password... (0 Replies)
Discussion started by: saps19
0 Replies

4. UNIX for Advanced & Expert Users

Cron Issue

I have written a custom cron. This cron executes a rake task every 5 minutes. I also log the trace of this execution in a file locally on my server. The whole process seems to execute seamlessly every 5 minutes, but then it seems to log it in /var/log/syslog. I investigated on the syslog and found... (0 Replies)
Discussion started by: manjunath.nm89
0 Replies

5. UNIX for Dummies Questions & Answers

CRON JOB SCHEDULER throwing "option not allowed error"

Hi All, Pardon me if this turns out to be a dumb question. But I am trying to schedule a cron job for a my script which takes input options. So an entry in crontab would be something like: 1 * * * * run_report.sh -o out.csv -m monthly -e somename@email.com > cron_output.log 2> cron_error.log... (3 Replies)
Discussion started by: trueharsh
3 Replies

6. Red Hat

cron issue

Hello, Having and issue with a job scheduled in cron. The script: #!/bin/bash 2 3 # Example shell script which can be added to roots cron job to check the 4 # Embedded Satellite disk space usage. If any table is over 90% usage, send 5 # a notice to the default email address... (2 Replies)
Discussion started by: mgb
2 Replies

7. Solaris

CRON Scheduler

I have akorn shell job that I can run manually but when I run via cron it starts and finishes, but does not do what it does when I run it manually. Any ideals on why this is happening? (3 Replies)
Discussion started by: CAGIRL
3 Replies

8. Shell Programming and Scripting

Unix scheduler other than Cron

Do any one know any way of scheduling jobs on Unix without using cron as thats not supported within the company (5 Replies)
Discussion started by: Yziee
5 Replies

9. Shell Programming and Scripting

Job scheduler without using cron

Hi, I want to schedule the scripts/batches to run simultaneously. I had all the information in the config (flat)file, which contains script name, time, dependency, path, priority and status etc., I want to run the jobs parellelly and some jobs are required to give the input. How can I do this?... (1 Reply)
Discussion started by: sharif
1 Replies
Login or Register to Ask a Question