Sponsored Content
Full Discussion: Scheduling scheduling !!!
Top Forums Shell Programming and Scripting Scheduling scheduling !!! Post 302594443 by Corona688 on Tuesday 31st of January 2012 10:33:21 AM
Old 01-31-2012
cron is a very poor way to do this. I'd recommend using a makefile instead.

Code:
$ cat Makefile

# Note that the eight spaces in front of things are actually tabs and MUST BE TABS
# for the makefile to work correctly.
all:j1 j2 j3 j4 j5 j6 j7 j8 j9 j10
        echo "all jobs complete"

j1:
        sleep 1 ; echo $@
j2:
        sleep 1 ; echo $@
j3:
        sleep 1 ; echo $@
j4:
        sleep 1 ; echo $@
j5:
        sleep 1 ; echo $@
j6:
        sleep 1 ; echo $@
j7:
        sleep 1 ; echo $@
j8:
        sleep 1 ; echo $@
j9:
        sleep 1 ; echo $@
j10:
        sleep 1 ; echo $@

$ make

sleep 1 ; echo j1
j1
sleep 1 ; echo j2
j2
sleep 1 ; echo j3
j3
sleep 1 ; echo j4
j4
sleep 1 ; echo j5
j5
sleep 1 ; echo j6
j6
sleep 1 ; echo j7
j7
sleep 1 ; echo j8
j8
sleep 1 ; echo j9
j9
sleep 1 ; echo j10
j10
echo "all jobs complete"
all jobs complete

# Takes 10 seconds to run each job individually
$ time make

sleep 1 ; echo j1
j1
sleep 1 ; echo j2
j2
sleep 1 ; echo j3
j3
sleep 1 ; echo j4
j4
sleep 1 ; echo j5
j5
sleep 1 ; echo j6
j6
sleep 1 ; echo j7
j7
sleep 1 ; echo j8
j8
sleep 1 ; echo j9
j9
sleep 1 ; echo j10
j10
echo "all jobs complete"
all jobs complete

real    0m10.032s
user    0m0.006s
sys     0m0.009s

# ...but only one when you run all the echo's in parallel
$ time make -j 10
sleep 1 ; echo j1
sleep 1 ; echo j2
sleep 1 ; echo j3
sleep 1 ; echo j4
sleep 1 ; echo j5
sleep 1 ; echo j6
sleep 1 ; echo j7
sleep 1 ; echo j8
sleep 1 ; echo j9
sleep 1 ; echo j10
j1
j2
j3
j4
j5
j7
j6
j8
j9
j10
echo "all jobs complete"
all jobs complete

real    0m1.017s
user    0m0.009s
sys     0m0.007s

$

If you insist, you should even be able to run make from cron, like this:

Code:
/usr/bin/make -C /path/to/dir/ -j 10 2> /dev/null

which will cause it to run the Makefile inside /path/to/dir.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

scheduling

i have tried to schedule my process at a certain time using the at command : the error says bad time specification can somebody help me i used at 2300 job thanks (2 Replies)
Discussion started by: prashantuc
2 Replies

2. HP-UX

cron scheduling?

Hi all, i want a job to run first monday of every of month. (1 Reply)
Discussion started by: megh
1 Replies

3. UNIX and Linux Applications

Job Scheduling

I am working on UNIX AIX system, with Oracle OS. We are not supposed to use any tools to schedule our unix shell scripts. Basically we have to make use of Oracle tables and Shell scripts to manage dependencies, restartability, scheduling, parallelizing,etc. If anyone has worked/ is working... (1 Reply)
Discussion started by: singhabhijit
1 Replies

4. Shell Programming and Scripting

Job Scheduling

I am working on UNIX AIX system, with Oracle OS. We are not supposed to use any tools to schedule our unix shell scripts. Basically we have to make use of Oracle tables and Shell scripts to manage dependencies, restartability, scheduling, parallelizing,etc. If anyone has worked/ is working... (4 Replies)
Discussion started by: singhabhijit
4 Replies

5. Programming

Time scheduling

Hello !!! i am trying to create a command scheduler (written in C). Basically i would like to do what the "at" command does , but without using "at" or "cron". I have tried using getitimer but i do not know how can i shcedule multiple commands. Any ideas ??? (2 Replies)
Discussion started by: mcnikolas
2 Replies

6. Linux

Help with cronjob scheduling

Hi Everybody, How to schedule a job using cron that shouldn't run between working hrs 9am-5pm, while run in non working hrs every hour, every day of the month, month & week. I tried the following way, not sure I can use logical not operator(!). Please correct me if wrong or suggest other... (2 Replies)
Discussion started by: sudhirav
2 Replies

7. Shell Programming and Scripting

Crontab scheduling

Hi all, My OS is Solaris 10. I want to schedule a job which i need to run between morining 6 to eve 6 once for every 2 hours. This is what i did. 0 6-18 * * 1-5 /monitor.sh It runs for every hour how to make it for every two hours ...... Thanks, Firestar. (1 Reply)
Discussion started by: firestar
1 Replies

8. Shell Programming and Scripting

help required on scheduling

hi I have a script, abc.sh first time user will start a script using <<abc.sh start >>, inside a script using " at " i am schduling same script for every one hour. so my script always running . total script execution time takes around 1sec for closing same << abc.sh stop>> here... (2 Replies)
Discussion started by: pvr_satya
2 Replies

9. Shell Programming and Scripting

Scheduling issues

I AM ON SOLARIS I have a script it.sh which is running fine when i execute it from shell command. But when i schedule it in crontab it is throwing error. Why and how can i resolve it ?i am clueless IT.SH #!/bin/sh ORACLE_HOME=/var/opt/oracle/product/10g; export ORACLE_HOME... (1 Reply)
Discussion started by: rafa_fed2
1 Replies

10. UNIX for Beginners Questions & Answers

Scheduling a script

Hi, I have my script in below path in UNIX /storage/sas_source/SDTM-Development/FileWatcher/filewatcher.sh I want to schedule it to run every 30 secs. Please let me know the steps to do it. Thanks. (7 Replies)
Discussion started by: prats_7678
7 Replies
queuedefs(4)							   File Formats 						      queuedefs(4)

NAME
queuedefs - queue description file for at, batch, and cron SYNOPSIS
/etc/cron.d/queuedefs DESCRIPTION
The queuedefs file describes the characteristics of the queues managed by cron(1M). Each non-comment line in this file describes one queue. The format of the lines are as follows: q.[njobj][nicen][nwaitw] The fields in this line are: q The name of the queue. a is the default queue for jobs started by at(1); b is the default queue for jobs started by batch (see at(1)); c is the default queue for jobs run from a crontab(1) file. njob The maximum number of jobs that can be run simultaneously in that queue; if more than njob jobs are ready to run, only the first njob jobs will be run, and the others will be run as jobs that are currently running terminate. The default value is 100. nice The nice(1) value to give to all jobs in that queue that are not run with a user ID of super-user. The default value is 2. nwait The number of seconds to wait before rescheduling a job that was deferred because more than njob jobs were running in that job's queue, or because the system-wide limit of jobs executing has been reached. The default value is 60. Lines beginning with # are comments, and are ignored. EXAMPLES
Example 1: A sample file. # # a.4j1n b.2j2n90w This file specifies that the a queue, for at jobs, can have up to 4 jobs running simultaneously; those jobs will be run with a nice value of 1. As no nwait value was given, if a job cannot be run because too many other jobs are running cron will wait 60 seconds before trying again to run it. The b queue, for batch(1) jobs, can have up to 2 jobs running simultaneously; those jobs will be run with a nice(1) value of 2. If a job cannot be run because too many other jobs are running, cron(1M) will wait 90 seconds before trying again to run it. All other queues can have up to 100 jobs running simultaneously; they will be run with a nice value of 2, and if a job cannot be run because too many other jobs are running cron will wait 60 seconds before trying again to run it. FILES
/etc/cron.d/queuedefs queue description file for at, batch, and cron. SEE ALSO
at(1), crontab(1), nice(1), cron(1M) SunOS 5.10 1 Mar 1994 queuedefs(4)
All times are GMT -4. The time now is 05:54 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy