Posts tagged as:

shell

Pause a Linux Shell Script using Sleep

by Ron on June 26, 2008

It’s easy to pause a shell script during execution. Just add:
sleep 10
(where 10 is the number of seconds you want the script to pause.)
Some code for testing would be…
#!/bin/sh
before=”$(date +%s)”
echo $before
sleep 3
after=”$(date +%s)”
echo $after
elapsed_seconds=”$(expr $after - $before)”
echo Elapsed time for code block: $elapsed_seconds

Have other ideas? Please comment.

{ 1 comment }

Shell script date calculations

by Ron on June 23, 2008

#!/bin/sh
before=”$(date +%s)”
echo $before
sleep 5
Ymd=”$(date ‘+%Y%m%d’)”
echo $Ymd
after=”$(date +%s)”
echo $after
elapsed_seconds=”$(expr $after - $before)”
echo Elapsed time for code block: $elapsed_seconds

{ 1 comment }