Shell script to schedule jobs


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell script to schedule jobs
# 1  
Old 10-24-2011
Shell script to schedule jobs

Dear all,
I have to create a shell script which will run the job during weekday/weekend in following manner: -
There are 3 jobs
Code:
JB_1 
JB_2
JB_3

These jobs changes its flag to "COMPLETED" in below 2 ways
1. These 3 jobs which runs after the completion of previous one i.e JB_1 runs and changes its flag to "COMPLETED" then only the next job gets started.
2. The second way to change the jobs status to "COMPLETED" without running it with the following command: -
Code:
CHANGE_FLAG JB_1=COMPLETED ---- if i run this command at the prompt followed job name= completed, it changes its flag.Same goes for JB_2 and JB_3

Now my concern is how should i create a shell script to do the above activities during weekday and weekend as mentioned below.

During weekday (Monday to friday) these jobs should simply change its flag to COMPLETED as mentioned in point 2.
During weekend (Saturday and Sunday) these job should run and then changes its flag to COMPLETED as mentioned in Point 1.
What these jobs internally does is irrelevant.
# 2  
Old 10-24-2011
whats wrong with using cron? why are you re-inventing the wheel?
# 3  
Old 10-24-2011
Crontab doesnt work here...need to write a shell script for that..
# 4  
Old 10-24-2011
Please post detailed explanation when you say something doesnt work. When you say crontab, are you saying there are problems with editing the cron entry or the cron daemon is not working or running?
# 5  
Old 10-24-2011
We use autosys and not crontab...
# 6  
Old 10-25-2011
Quote:
Originally Posted by BeefStu
whats wrong with using cron? why are you re-inventing the wheel?
There are other schedulers that are more sophisticated than cron. In this case it sounds like the scheduler of choice provides conditional execution where Job-b depends on the successful execution of Job-a and thus Job-b isn't run until Job-a finishes and was successful. Cron makes no provision for conditional execution and thus isn't useful.

Quote:
Now my concern is how should i create a shell script to do the above activities during weekday and weekend as mentioned below.

During weekday (Monday to friday) these jobs should simply change its flag to COMPLETED as mentioned in point 2.
During weekend (Saturday and Sunday) these job should run and then changes its flag to COMPLETED as mentioned in Point 1.
What these jobs internally does is irrelevant.
Something like this might be what you need. During the week, it executes the change flag script/programme and exits (good). On Saturday and Sunday it executes what ever you need.

Code:
#!/usr/bin/env ksh

case $(date +%a) in
    Sun|Sat)    ;;     # do nothing here, do real work after the case

    *)      CHANGE_FLAG JB_1=COMPLETED;   # nothing to be done, just change and exit 
            exit 0
            ;;
esac

echo "doing the real work now"
CHANGE_FLAG JB_1=COMPLETED
exit 0

Should work in bash too.
This User Gave Thanks to agama For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Schedule a shell script without crontab every Wednesday at 10 AM

HI Guys I need one shell script to be scheduled to run one shell script to be executed automatically every Wednesday at 10 AM Without crontab and "at" command.. Could you provide your suggestions ? Thanks and Regards kshitij Kulshreshtha (6 Replies)
Discussion started by: kshitij
6 Replies

2. Shell Programming and Scripting

Shell script to run multiple jobs and it's dependent jobs

I have multiple jobs and each job dependent on other job. Each Job generates a log and If job completed successfully log file end's with JOB ENDED SUCCESSFULLY message and if it failed then it will end with JOB ENDED with FAILURE. I need an help how to start. Attaching the JOB dependency... (3 Replies)
Discussion started by: santoshkumarkal
3 Replies

3. Shell Programming and Scripting

Want to Schedule Shell Script on AIX

Hi All, I want to schedule a shell script on AIX. But Crontab is not working in my AIX Server.Is there any alternative? Please Suggest.. (2 Replies)
Discussion started by: bharat1211
2 Replies

4. Shell Programming and Scripting

How to schedule a shell script in Linux centos?

Hi All, I have a script that I need to schedule on daily basis. How can I schedule a script in centos. Like I want to run that script evryday at 10 AM and can I store the output of the script in a log file. Thanks ---------- Post updated 04-18-14 at 12:52 AM ---------- Previous update... (0 Replies)
Discussion started by: Palak Sharma
0 Replies

5. 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

6. Shell Programming and Scripting

Schedule tasks in shell script

shell=ksh, How could I schedule tasks in shell script INSTEAD OF using the crontab -e functionality? For example, I want a script to print "Hello World" every 10 seconds (i.e., INTERVAL = 10s) until external termination signal is triggered. Thanks, (2 Replies)
Discussion started by: isaacniu
2 Replies

7. 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

8. Shell Programming and Scripting

how to schedule no of jobs based on the value from the oracle table

Hi all, Please help me with the issue im facing. my client has a recquirement that unix script has to schedule the no.of jobs based on the value from the oracle table.for example if the table has a value of 20 the unix script has to schedule 20 jobs.im able to write the script to get the value... (1 Reply)
Discussion started by: srikanths2s
1 Replies

9. Shell Programming and Scripting

Schedule an interactive shell script

Hi, I need to schedule a shell script which executes another shell script along with a series of other commands. When the inner shell script is executed it prompts for a password..... This inner shell cannot be changed How can I do this???? Regards, Chaitrali. (4 Replies)
Discussion started by: Chaitrali
4 Replies

10. UNIX for Dummies Questions & Answers

schedule many jobs using cron

HI, I need to schedule a no.of jobs using the cron facility. I currently do two kinds of scheduling,one based on the database load(after the database is loaded the program will start) and the other is based on time.....(say 10.00a.m daily) the problem is.......... When the database is loaded... (1 Reply)
Discussion started by: sireesha15
1 Replies
Login or Register to Ask a Question