Re: variables in the run script

From: Peter Pentchev <>
Date: Wed, 9 Oct 2013 10:58:48 +0300

On Tue, Oct 08, 2013 at 08:12:06PM +0200, Subba Rao 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?

Can you post your *entire* exact script, including the shebang line?

If you do not have a shebang line, then try adding '#!/bin/bash' as
the first line of your script - and yes, since you're using
Bash-specific features, you do need to specify #!/bin/bash to make sure
that nothing tries to run your script using, say, /bin/sh, which might
be Bash or it might not be Bash, or it might be Bash behaving strangely
because it has been invoked as /bin/sh, or who knows what else :)


Peter Pentchev
PGP key:
Key fingerprint 2EE7 A7A5 17FC 124C F115  C354 651E EFB0 2527 DF13
If I had finished this sentence,

Received on Wed Oct 09 2013 - 07:58:48 UTC

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