FAQ
I have a script file in my cron.hourly that contains a good number of
scripts I must call.


#!/bin/sh


sleep 15
perl /scripts/create_graph.pl &


sleep 15
perl /scripts/create_graph_out.pl &


many more lines. etc.


Is there a way I can sleep random length to time before executing each
but background each one so master script returns promptly. Something
like.


sleep (random 1 - 300 seconds, perl /scripts/create_graph_out.pl) &

Search Discussions

  • Stephen Harris at Sep 5, 2013 at 3:28 pm

    On Thu, Sep 05, 2013 at 10:24:55AM -0500, Matt wrote:
    I have a script file in my cron.hourly that contains a good number of
    scripts I must call.

    #!/bin/sh

    sleep 15
    perl /scripts/create_graph.pl &

    sleep 15
    perl /scripts/create_graph_out.pl &

    many more lines. etc.

    Don't background them individually; background the whole lot


    #!/bin/sh
    (
       perl /scripts/create_graph.pl
       perl /scripts/create_graph_out.pl
       etc
    ) &


    Now they will run one after another and you don't need to sleep
    between them.




    --


    rgds
    Stephen
  • Tony Sweeney at Sep 5, 2013 at 3:40 pm
    LIMIT # Or whatever
    sleep `expr $RANDOM % $LIMIT + 1`


    -----Original Message-----
    From: centos-bounces at centos.org [mailto:centos-bounces at centos.org] On Behalf Of Matt
    Sent: 05 September 2013 16:25
    To: CentOS mailing list
    Subject: [CentOS] Shell Script Help


    I have a script file in my cron.hourly that contains a good number of scripts I must call.


    #!/bin/sh


    sleep 15
    perl /scripts/create_graph.pl &


    sleep 15
    perl /scripts/create_graph_out.pl &


    many more lines. etc.


    Is there a way I can sleep random length to time before executing each but background each one so master script returns promptly. Something like.


    sleep (random 1 - 300 seconds, perl /scripts/create_graph_out.pl) & _______________________________________________
    CentOS mailing list
    CentOS at centos.org
    http://lists.centos.org/mailman/listinfo/centos


    ______________________________________________________________________
    This email has been scanned by the Symantec Email Security.cloud service.
    For more information please visit http://www.symanteccloud.com ______________________________________________________________________


    -----
    No virus found in this message.
    Checked by AVG - www.avg.com
    Version: 2013.0.3392 / Virus Database: 3211/6618 - Release Date: 08/28/13 Internal Virus Database is out of date.


    ______________________________________________________________________
    This email has been scanned by the Symantec Email Security.cloud service.
    For more information please visit http://www.symanteccloud.com
    ______________________________________________________________________
  • Mark LaPierre at Sep 6, 2013 at 1:33 am

    On 09/05/2013 11:24 AM, Matt wrote:
    I have a script file in my cron.hourly that contains a good number of
    scripts I must call.

    #!/bin/sh

    sleep 15
    perl /scripts/create_graph.pl &

    sleep 15
    perl /scripts/create_graph_out.pl &

    many more lines. etc.

    Is there a way I can sleep random length to time before executing each
    but background each one so master script returns promptly. Something
    like.

    sleep (random 1 - 300 seconds, perl /scripts/create_graph_out.pl) &
    _______________________________________________
    CentOS mailing list
    CentOS at centos.org
    http://lists.centos.org/mailman/listinfo/centos

    If you are trying to avoid running all these perl scripts concurrently
    set up the perl scripts to accept an argument, then pass each one a time
    delay when you call them.


    PerlScript-1 20 &
    PerlScript-2 40 &
    ...
    PerlScript-n n*20 &


    The calling script will return almost immediately but the perl scripts
    will delay any action for the specified time. That way the time delay
    is fully adjustable from zero to forever.


    --
         _
        ?v?
       /(_)\
        ^ ^ Mark LaPierre
    Registered Linux user No #267004
    https://linuxcounter.net/
    ****
  • Nicolas Thierry-Mieg at Sep 6, 2013 at 12:44 pm

    Matt wrote:
    I have a script file in my cron.hourly that contains a good number of
    scripts I must call.

    #!/bin/sh

    sleep 15
    perl /scripts/create_graph.pl &

    sleep 15
    perl /scripts/create_graph_out.pl &

    many more lines. etc.

    Is there a way I can sleep random length to time before executing each
    but background each one so master script returns promptly. Something
    like.

    sleep 15 && perl /scripts/create_graph.pl &
    should return promptly, another reply addresses the random part.
  • Marc Wiatrowski at Sep 6, 2013 at 1:05 pm

    On Fri, Sep 6, 2013 at 8:44 AM, Nicolas Thierry-Mieg wrote:


    Matt wrote:
    I have a script file in my cron.hourly that contains a good number of
    scripts I must call.

    #!/bin/sh

    sleep 15
    perl /scripts/create_graph.pl &

    sleep 15
    perl /scripts/create_graph_out.pl &

    many more lines. etc.

    Is there a way I can sleep random length to time before executing each
    but background each one so master script returns promptly. Something
    like.
    sleep 15 && perl /scripts/create_graph.pl &
    should return promptly, another reply addresses the random part.

      sleep $(($RANDOM%300))

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcentos @
categoriescentos
postedSep 5, '13 at 3:24p
activeSep 6, '13 at 1:05p
posts6
users6
websitecentos.org
irc#centos

People

Translate

site design / logo © 2021 Grokbase