How Does Sleep Behavior Work When My Computer Suspends?

0
0
Asked By CuriousCoder92 On

I'm trying to create a script that updates my wallpaper every hour using the command 'waypaper --random' in an infinite loop. Here's the basic structure I'm using:

while :
do
sleep 3600
waypaper --random
done

I'm pretty new to this, so I'm not sure if this is the best approach. The real question I have is about the behavior of the sleep command when my system goes into suspension. My computer suspends after 30 minutes of inactivity. If it suspends right at the 30-minute mark and then wakes up an hour later, what happens to the sleep timer? Does it continue counting from that 30-minute mark, meaning it would wait another 30 minutes before running the wallpaper change, or does it start from 0 and immediately run the command? I'd really appreciate any insight before I just go and test it with some echo commands.

1 Answer

Answered By SimpleScriptor On

You might want to consider using cron instead of a script loop. It can manage tasks on a schedule without worrying about the system being suspended. Just set your wallpaper change in cron to run every hour, and it should work fine even when your machine wakes up. But if you're stuck setting up cron, I'd be happy to help you out with that!

LostInScripts -

Yeah, I tried cron but couldn't get it to execute my script. I added it to the '@reboot' section but it just wouldn’t run for me.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.