AIX

AIX

Connect with fellow AIX users and experts to gain knowledge, share insights, and solve problems.

 View Only
Expand all | Collapse all

Start Script in Background to Run for Specifc Interval in AIX

  • 1.  Start Script in Background to Run for Specifc Interval in AIX

    Posted Tue September 09, 2014 07:38 AM

    Originally posted by: s_m_gopinath


    Greetings guys, 

    I'm writing a kshell script to monitor the server and store historical data of it for every 5 seconds interval. I now want to run the shell script for a specific interval after calling it when ever I call it for example when I invoke it the script should run for 1 hour collecting the historical data for every 5 seconds and stop. I can't use a crontab for this, let me know if there is a way for this in kshell. 

    OS: AIX 6.1 

    With regards, 
    Gopinath.



  • 2.  Re: Start Script in Background to Run for Specifc Interval in AIX

    Posted Wed September 10, 2014 01:29 AM

    Originally posted by: 8WYC_Ujwal_Modhukalya


    use below script for resolving this issue, and run this master script as below

     

    ./script_name 1 &

    1= for 1 hour,  you can use this script argu for 1 hour , 2hours, 3 hours etc.

     

    #!/bin/ksh
    val=$(( $1 * 720 ))
    while [[ $val -gt 0 ]]
    do
    echo " Remove this line and put your script here $val"
    sleep 5
    (( val -= 1 ))
    done