Linux / UNIX - at command delays running - Unix

This is a discussion on Linux / UNIX - at command delays running - Unix ; Lets say my interval is 5 minutes. My master script runs a 2nd script, then schedules 2nd script using "at" to run every minute for the interval. The master script then sleeps for the interval (5 min). It then calls ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: Linux / UNIX - at command delays running

  1. Linux / UNIX - at command delays running

    Lets say my interval is 5 minutes.
    My master script runs a 2nd script, then schedules 2nd script using
    "at" to run every minute for the interval.
    The master script then sleeps for the interval (5 min).
    It then calls the second script one last time.

    Once and a while some of the at commands do not run on the minute they
    should. They run along with anouther at. Such as (debug commands
    output each script start time):
    Wed Aug 20 19:16:42 UTC 2008. PID= 18634. Should be=Wed Aug 20
    19:16:42 UTC 2008 >>> 18633 First Run:
    Wed Aug 20 19:17:02 UTC 2008. PID= 18706. Should be=Wed Aug 20
    19:16:42 UTC 2008 + 1 . PPID=18633
    Wed Aug 20 19:18:01 UTC 2008. PID= 18773. Should be=Wed Aug 20
    19:16:43 UTC 2008 + 2 . PPID=18633
    Wed Aug 20 19:20:17 UTC 2008. PID= 19186. Should be=Wed Aug 20
    19:16:43 UTC 2008 + 4 . PPID=18633
    Wed Aug 20 19:20:17 UTC 2008. PID= 19200. Should be=Wed Aug 20
    19:16:43 UTC 2008 + 3 . PPID=18633
    Wed Aug 20 19:21:00 UTC 2008. PID= 19429. Should be=Wed Aug 20
    19:16:43 UTC 2008 + 5 . PPID=18633
    Wed Aug 20 19:21:44 UTC 2008. PID= 19463. Should be=Wed Aug 20
    19:21:44 UTC 2008 <<< 18633 Final run:

    Notice 19:20:17 two of the ats go off.

    For the purposes of diagnosing this problem I created this watered
    down version of my script which re-created the error. However the
    error doesnt present itself every time only once and a while. It seems
    to occur more often when the box is cpu stressed. The box was suse
    linux ppc64. However this error happens on more than one operating
    system.

    My master script:
    #!/bin/sh
    intvlsize=5
    ../test.sh `date -u` ">>> $$ First Run:" &
    atctr=1
    while [ $atctr -le $intvlsize ]; do
    echo "`pwd`/test.sh `date -u` + $atctr . PPID=$$" > atcommand
    cat atcommand | at now +$atctr minutes
    atctr=`expr $atctr + 1`
    done
    sleep 300
    ../test.sh `date -u` "<<< $$ Final run:"
    echo

    test.sh:
    echo "`date -u`. PID= $$. Should be=$@" >> $HOME/at_test/test.log 2>&1
    sleep 20

    Any ideas as to what may be causing these errors?

  2. Re: Linux / UNIX - at command delays running

    Stephen wrote:
    > Lets say my interval is 5 minutes.
    > My master script runs a 2nd script, then schedules 2nd script using
    > "at" to run every minute for the interval.
    > The master script then sleeps for the interval (5 min).
    > It then calls the second script one last time.
    >
    > Once and a while some of the at commands do not run on the minute they
    > should. They run along with anouther at. Such as (debug commands
    > output each script start time):
    > Wed Aug 20 19:16:42 UTC 2008. PID= 18634. Should be=Wed Aug 20
    > 19:16:42 UTC 2008 >>> 18633 First Run:
    > Wed Aug 20 19:17:02 UTC 2008. PID= 18706. Should be=Wed Aug 20
    > 19:16:42 UTC 2008 + 1 . PPID=18633
    > Wed Aug 20 19:18:01 UTC 2008. PID= 18773. Should be=Wed Aug 20
    > 19:16:43 UTC 2008 + 2 . PPID=18633
    > Wed Aug 20 19:20:17 UTC 2008. PID= 19186. Should be=Wed Aug 20
    > 19:16:43 UTC 2008 + 4 . PPID=18633
    > Wed Aug 20 19:20:17 UTC 2008. PID= 19200. Should be=Wed Aug 20
    > 19:16:43 UTC 2008 + 3 . PPID=18633
    > Wed Aug 20 19:21:00 UTC 2008. PID= 19429. Should be=Wed Aug 20
    > 19:16:43 UTC 2008 + 5 . PPID=18633
    > Wed Aug 20 19:21:44 UTC 2008. PID= 19463. Should be=Wed Aug 20
    > 19:21:44 UTC 2008 <<< 18633 Final run:
    >
    > Notice 19:20:17 two of the ats go off.
    >
    > For the purposes of diagnosing this problem I created this watered
    > down version of my script which re-created the error. However the
    > error doesnt present itself every time only once and a while. It seems
    > to occur more often when the box is cpu stressed. The box was suse
    > linux ppc64. However this error happens on more than one operating
    > system.
    >
    > My master script:
    > #!/bin/sh
    > intvlsize=5
    > ./test.sh `date -u` ">>> $$ First Run:" &
    > atctr=1
    > while [ $atctr -le $intvlsize ]; do
    > echo "`pwd`/test.sh `date -u` + $atctr . PPID=$$" > atcommand
    > cat atcommand | at now +$atctr minutes
    > atctr=`expr $atctr + 1`
    > done
    > sleep 300
    > ./test.sh `date -u` "<<< $$ Final run:"
    > echo
    >
    > test.sh:
    > echo "`date -u`. PID= $$. Should be=$@" >> $HOME/at_test/test.log 2>&1
    > sleep 20
    >
    > Any ideas as to what may be causing these errors?



    cron checks every minute for an at job.
    Dependent on the time slot when you create an at job,
    the delay can be 0-60 seconds.

    Why not directly fire the background jobs in the script?

    while [ $atctr -le $intvlsize ]; do
    (
    sleep $((atctr * 60))
    atcommand /dev/null 2>&1
    ) &
    actr=$((atctr + 1))
    done
    sleep 300

    Maybe the delays can be even done in the foreground?

    while [ $atctr -le $intvlsize ]; do
    sleep 60
    atcommand /dev/null 2>&1 &
    actr=$((atctr + 1))
    done


    --
    echo imhcea\.lophc.tcs.hmo |
    sed 's2\(....\)\(.\{5\}\)2\2\122;s1\(.\)\(.\)1\2\11g;1 s;\.;::;2'

  3. Re: Linux / UNIX - at command delays running

    Michael Tosch wrote:
    > Stephen wrote:
    >> Lets say my interval is 5 minutes.
    >> My master script runs a 2nd script, then schedules 2nd script using
    >> "at" to run every minute for the interval.
    >> The master script then sleeps for the interval (5 min).
    >> It then calls the second script one last time.
    >>
    >> Once and a while some of the at commands do not run on the minute they
    >> should. They run along with anouther at. Such as (debug commands
    >> output each script start time):
    >> Wed Aug 20 19:16:42 UTC 2008. PID= 18634. Should be=Wed Aug 20
    >> 19:16:42 UTC 2008 >>> 18633 First Run:
    >> Wed Aug 20 19:17:02 UTC 2008. PID= 18706. Should be=Wed Aug 20
    >> 19:16:42 UTC 2008 + 1 . PPID=18633
    >> Wed Aug 20 19:18:01 UTC 2008. PID= 18773. Should be=Wed Aug 20
    >> 19:16:43 UTC 2008 + 2 . PPID=18633
    >> Wed Aug 20 19:20:17 UTC 2008. PID= 19186. Should be=Wed Aug 20
    >> 19:16:43 UTC 2008 + 4 . PPID=18633
    >> Wed Aug 20 19:20:17 UTC 2008. PID= 19200. Should be=Wed Aug 20
    >> 19:16:43 UTC 2008 + 3 . PPID=18633
    >> Wed Aug 20 19:21:00 UTC 2008. PID= 19429. Should be=Wed Aug 20
    >> 19:16:43 UTC 2008 + 5 . PPID=18633
    >> Wed Aug 20 19:21:44 UTC 2008. PID= 19463. Should be=Wed Aug 20
    >> 19:21:44 UTC 2008 <<< 18633 Final run:
    >>
    >> Notice 19:20:17 two of the ats go off.
    >>
    >> For the purposes of diagnosing this problem I created this watered
    >> down version of my script which re-created the error. However the
    >> error doesnt present itself every time only once and a while. It seems
    >> to occur more often when the box is cpu stressed. The box was suse
    >> linux ppc64. However this error happens on more than one operating
    >> system.
    >>
    >> My master script:
    >> #!/bin/sh
    >> intvlsize=5
    >> ./test.sh `date -u` ">>> $$ First Run:" &
    >> atctr=1
    >> while [ $atctr -le $intvlsize ]; do
    >> echo "`pwd`/test.sh `date -u` + $atctr . PPID=$$" > atcommand
    >> cat atcommand | at now +$atctr minutes
    >> atctr=`expr $atctr + 1`
    >> done
    >> sleep 300
    >> ./test.sh `date -u` "<<< $$ Final run:"
    >> echo
    >>
    >> test.sh:
    >> echo "`date -u`. PID= $$. Should be=$@" >> $HOME/at_test/test.log 2>&1
    >> sleep 20
    >>
    >> Any ideas as to what may be causing these errors?

    >
    >
    > cron checks every minute for an at job.
    > Dependent on the time slot when you create an at job,
    > the delay can be 0-60 seconds.
    >
    > Why not directly fire the background jobs in the script?
    >
    > while [ $atctr -le $intvlsize ]; do
    > (
    > sleep $((atctr * 60))
    > atcommand /dev/null 2>&1
    > ) &
    > actr=$((atctr + 1))
    > done
    > sleep 300


    Correction:

    while [ $atctr -le $intvlsize ]; do
    (
    sleep $((atctr * 60))
    atcommand
    ) /dev/null 2>&1 &
    actr=$((atctr + 1))
    done
    sleep 300

    >
    > Maybe the delays can be even done in the foreground?
    >
    > while [ $atctr -le $intvlsize ]; do
    > sleep 60
    > atcommand /dev/null 2>&1 &
    > actr=$((atctr + 1))
    > done
    >
    >



    --
    echo imhcea\.lophc.tcs.hmo |
    sed 's2\(....\)\(.\{5\}\)2\2\122;s1\(.\)\(.\)1\2\11g;1 s;\.;::;2'

+ Reply to Thread