Schedule a script to run at 10am from mon to fri


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Schedule a script to run at 10am from mon to fri
# 1  
Old 01-20-2011
Schedule a script to run at 10am from mon to fri

Hi,

I need to write a shell script which will run i background and will execute other script only on Mon to Fri 10 AM but not on Sat and Sun.

I am able to set it to run on every day at 10AM but how to make it to run only on Mon to Fri

Thanks,
Firestar.
# 2  
Old 01-20-2011
the entry should be like this..

00 10 * * 1-5 your script
# 3  
Old 01-20-2011
@everurs789

Sorry to confuse you....

i dont have access to crontab i need to write in shell scriptt..
# 4  
Old 01-20-2011
date +%u returns the number of the day in the current week. (1 is monday, 2 is tuesday, ...)
You can write something like :
Code:
if [ $(date +%u) -lt 6 ]; then
   echo 'command to execute'
fi

to get the job done Smilie
This User Gave Thanks to tukuyomi For This Post:
# 5  
Old 01-20-2011
@tukuyomi

Thank you.
For Sat its 6
and Sun its 7
is dat correct..
# 6  
Old 01-20-2011
It is correct. See "man date".



As you noticed, Sunday is day zero in cron ... but day seven in "date +%u".
Just for interest "date +%w" gives the Weekday numbered the same way as cron.

Ps. We need to know whether "the script" does anything other than sit there idling and fire off another script at 10:00 on weekdays. How accurate does 10:00 need to be? Would up to 59 seconds either way matter?

Can you post your incomplete script?
This User Gave Thanks to methyl For This Post:
# 7  
Old 01-20-2011
Downside is if the system is re-booted, put in single user mode or your script dies the job won't run. Perhaps you could add something to your .profile so when you login it checks the script is still running and fires it off again.

Another thought, do you have access to run at jobs?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Schedule Job Fortnightly (FRI) in Crontab

Solaris platform. How can I schedule crontab job every 2 weeks and the job to be scheduled on Fri? (7 Replies)
Discussion started by: KhawHL
7 Replies

2. Shell Programming and Scripting

Schedule and Run By weekly shell script in cronjob

Hi All, How to schedule a shell script(script name- byweeklyreport.sh) it should run by weekly in corn job or is there any script have to write to check week and then run the above script. example-1st run March 06 2013 2nd run March 20 2013 3rd run April 3 2013... (13 Replies)
Discussion started by: krupasindhu18
13 Replies

3. AIX

job run before schedule on crontab

Guys, yesterday i just make a script with email as a result and put them into crontab, it will execute on 23.33. Today, i recieved email from system twice as result the script. the first email send at 23.02 and the second send at 23.33 how is the script execute two times ? the first job run... (6 Replies)
Discussion started by: michlix
6 Replies

4. UNIX for Dummies Questions & Answers

Best way to schedule script to run Ubuntu 10.04

On Ubuntu 10.04 LTS, I would like to know the best way to schedule myscript.sh to run at a specified time, please provide examples and specify things like does cron have to be running, how do I check if cron is running and all that. I have tried unsuccessfully in the past to run the AT command,... (1 Reply)
Discussion started by: glev2005
1 Replies

5. Shell Programming and Scripting

How to schedule a cronjob to run every 15 mins ?

Hi, I want to schedule a job to run every 15 mins through cron. searched the forums and came up with this piece of code.i have given this in my crontab 0-59/15 * * * * sh /usr/ss/job But its not being run. Have i made any mistake here. Can any1 post the cron code for scheduling the... (5 Replies)
Discussion started by: suresh_kb211
5 Replies

6. Shell Programming and Scripting

General Q: how to run/schedule a php script from cron jobs maybe via bash from shell?

Status quo is, within a web application, which is coded completely in php (not by me, I dont know php), I have to fill out several fields, and execute it manually by clicking the "go" button in my browser, several times a day. Thats because: The script itself pulls data (textfiles) from a... (3 Replies)
Discussion started by: lowmaster
3 Replies

7. Solaris

crontab to run mon.wed.fri

I have it set to the following 0 9 * * 1,3,5 /var/tmp/sys_diag It ran correctly on Wednesday but did not run on Friday and I am not sure why, does the above appear to be correct? (3 Replies)
Discussion started by: deaconf19
3 Replies

8. Solaris

Schedule to run every 3 minutes - CRONTAB

Hello all, I want to run a script every 3 minutes in os level and to send mail. I scheduled in crontab as 3 * * * * /mnt1/monitorscripts/testdbstart.sh I got mail every one hour and I confirmed that the script is running every 1 hour which doesn't meet my requirment. Where I am... (4 Replies)
Discussion started by: prashanth_gs
4 Replies

9. Shell Programming and Scripting

set schedule to run a script at background while logout

Hi, How can I run a script at 9:00am and 6:00pm everyday? Can I run it at background while I logout my account? Please help!! Many Thanks!! (1 Reply)
Discussion started by: happyv
1 Replies

10. UNIX for Dummies Questions & Answers

How do you schedule a command to run at 4:00 every morning?

How do you schedule a command to run at 4:00 every morning? (1 Reply)
Discussion started by: JosephGerard
1 Replies
Login or Register to Ask a Question