Re: variables in the run script

From: Subba Rao <umroute_at_tanucoo.com>
Date: Wed, 09 Oct 2013 06:23:46 +0200

Please ignore the syntax for the moment which can easily be fixed.

I have this script in my home directory and it works great. The log
file shows me the random #hours the loop is going to sleep. I copied
the logic into "run" and it does not work. The random #hours is always
0 in the log file. As a result, while loop does not rest.

Why is the code working as a normal script but not as "run"? The
service with "run" is owned by root user.

Subbarao


On 10/9/13 2:01 AM, Matthew Hannigan wrote:
> Is this is the entire script?
> The /* .. */ is a definite worry.
>
> My guess is it's being run by something other than bash.
> Try putting #!/bin/bash as the first line.
>
> _at_Wayne, $RANDOM is a bash builtin. It's different each time you use it.
> You can update it -- sort of. It just seeds the random number
> generator -- in case you want predictable random sequences.
>
> Regards,
> Matt
>
>
>
> On Wed, Oct 9, 2013 at 5:12 AM, Subba Rao <umroute_at_tanucoo.com
> <mailto:umroute_at_tanucoo.com>> wrote:
>
> I have a run script that has an infinite loop performing some
> cleanup functions, system monitoring functions etc. Once the
> tasks in one loop cycle are completed, I want the loop in "run"
> script to sleep for some random #hours before starting a new loop
> cycle. I have been trying to use the $RANDOM in bash for the
> sleep time.
>
> while :
> do
> Function1
> Function2
> slp=$(( $RANDOM % 14 + 22)) /* Any number from 22 to 36 */
> zzz="${slp}h" /* Append "h" for hours */
> echo $zzz >> ./log.txt /* echo $zzz to log file */
> sleep $zzz /* sleep for $slp hours */
> done
>
> The problem is this script works fine when I test it in my home
> directory. When I put the code into "run" script, there is no
> value for $slp or $zzz.
>
> Can the "run" script have some bash code in it with some logic
> required for the service? How can I fix/implement this solution?
>
> Thank you in advance.
>
> Regards,
>
> Subbarao
>
Received on Wed Oct 09 2013 - 04:23:46 UTC

This archive was generated by hypermail 2.3.0 : Sun May 09 2021 - 19:44:18 UTC