LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   sleep scripts (https://www.linuxquestions.org/questions/linux-newbie-8/sleep-scripts-4175443478/)

mreff555 12-30-2012 10:20 AM

sleep scripts
 
Does anyone have a good sleep script?

The commands below work great as long as I have superuser access and I type the command myself.

I would like to come up with an idle script and have had much trouble doing this. I haven't found anything online.
The only way I know to get idle time is from the "w" command but that is only based on individual programs and not the system.

I also don't want to introduce a loop that will tax the processor too much.

Any ideas on a good way to do this?

Code:

echo mem|tee /sys/power/state

or

echo disk|tee /sys/power/state


alieblice 12-30-2012 12:38 PM

im not sure if doing this going to work and if its safe but putting suid on your script might solve the problem .
make your scrip by super user and put sgid on it by chmod command. whenever a user exceute it , it will execute as super user.

mreff555 12-30-2012 06:09 PM

Right, I'm hoping to avoid that. what would be better if I could slip a couple of if statements in to a script periodically run with root permissions. The problem is that I don't know any scripts that are periodically run.


All times are GMT -5. The time now is 09:30 PM.