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
SYSTEMD-SUSPEND.SERVICE(8)                                    systemd-suspend.service                                   SYSTEMD-SUSPEND.SERVICE(8)

NAME
systemd-suspend.service, systemd-hibernate.service, systemd-hybrid-sleep.service, systemd-suspend-then-hibernate.service, systemd-sleep - System sleep state logic SYNOPSIS
systemd-suspend.service systemd-hibernate.service systemd-hybrid-sleep.service systemd-suspend-then-hibernate.service /lib/systemd/system-sleep DESCRIPTION
systemd-suspend.service is a system service that is pulled in by suspend.target and is responsible for the actual system suspend. Similarly, systemd-hibernate.service is pulled in by hibernate.target to execute the actual hibernation. Finally, systemd-hybrid-sleep.service is pulled in by hybrid-sleep.target to execute hybrid hibernation with system suspend and pulled in by suspend-then-hibernate.target to execute system suspend with a timeout that will activate hibernate later. Immediately before entering system suspend and/or hibernation systemd-suspend.service (and the other mentioned units, respectively) will run all executables in /lib/systemd/system-sleep/ and pass two arguments to them. The first argument will be "pre", the second either "suspend", "hibernate", "hybrid-sleep", or "suspend-then-hibernate" depending on the chosen action. Immediately after leaving system suspend and/or hibernation the same executables are run, but the first argument is now "post". All executables in this directory are executed in parallel, and execution of the action is not continued until all executables have finished. Note that scripts or binaries dropped in /lib/systemd/system-sleep/ are intended for local use only and should be considered hacks. If applications want to react to system suspend/hibernation and resume, they should rather use the Inhibitor interface[1]. Note that systemd-suspend.service, systemd-hibernate.service, and systemd-hybrid-sleep.service systemd-suspend-then-hibernate.service should never be executed directly. Instead, trigger system sleep states with a command such as "systemctl suspend" or similar. Internally, this service will echo a string like "mem" into /sys/power/state, to trigger the actual system suspend. What exactly is written where can be configured in the "[Sleep]" section of /etc/systemd/sleep.conf or a sleep.conf.d file. See systemd-sleep.conf(5). OPTIONS
systemd-sleep understands the following commands: -h, --help Print a short help text and exit. --version Print a short version string and exit. suspend, hibernate, hybrid-sleep, suspend-then-hibernate Suspend, hibernate, suspend then hibernate, or put the system to hybrid sleep. SEE ALSO
systemd-sleep.conf(5), systemd(1), systemctl(1), systemd.special(7), systemd-halt.service(8) NOTES
1. Inhibitor interface https://www.freedesktop.org/wiki/Software/systemd/inhibit systemd 237 SYSTEMD-SUSPEND.SERVICE(8)
All times are GMT -4. The time now is 08:27 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy