Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: unix sleep and date commands  (Read 6342 times)

0 Members and 1 Guest are viewing this topic.

fanco

  • Guest
unix sleep and date commands
« on: October 04, 2007, 10:12:39 AM »
please help me to fix my script trying to use sleep 2 minutes while the system is sleeping i want to print out same message every 5 seconds
thanks
t=`date +%S`

while [ t = t+120 ]
do
sleep 5

echo "this program will end in 2 minute"
done



michaewlewis



    Intermediate
  • Thanked: 26
    • Yes
    • Yes
  • Experience: Expert
  • OS: Unknown
Re: unix sleep and date commands
« Reply #1 on: October 04, 2007, 01:36:08 PM »
I don't know if you can make a computer do anything while it is sleeping. It usually pauses all processes so it can enter a low power state.
You're not trying to create a screensaver are you?

Deerpark



    Egghead
  • Thanked: 1
    Re: unix sleep and date commands
    « Reply #2 on: October 04, 2007, 01:56:08 PM »
    It's not that kind of sleeping michaewlewis... its a sleep command in a script.
    I.e. he wants the script to pause for a set time.

    fanco it would probably help with some more details... including what kind of scripting language you're using.
    Any sufficiently advanced technology is indistinguishable from magic.
    Arthur C. Clarke (1917 - 2008)

    ghostdog74



      Specialist

      Thanked: 27
      Re: unix sleep and date commands
      « Reply #3 on: October 04, 2007, 05:30:16 PM »
      please help me to fix my script trying to use sleep 2 minutes while the system is sleeping i want to print out same message every 5 seconds
      thanks
      t=`date +%S`

      while [ t = t+120 ]
      do
      sleep 5

      echo "this program will end in 2 minute"
      done




      Code: [Select]
      t=$(date +%S)
      t=`echo $t+120 |bc`
      echo "this program will end in 2 minutes from now"
      sleep $t
      exit