How to run a script when your computer is idle


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to run a script when your computer is idle
# 1  
Old 03-19-2005
MySQL How to run a script when your computer is idle

I am trying to run a script that I made when my computer is idle. How do I go about doing this.

Thanks Smilie
This User Gave Thanks to rehansaeed For This Post:
# 2  
Old 03-19-2005
Cron

Go to a shell type in man cron

For everyone else's benefit here is the description:

cron starts a process that executes commands at specified
dates and times.

You can specify regularly scheduled commands to cron accord-
ing to instructions found in crontab files in the directory
/var/spool/cron/crontabs. Users can submit their own crontab
file using the crontab(1) command. Commands which are to be
executed only once can be submitted using the at(1) command.

cron only examines crontab or at command files during its
own process initialization phase and when the crontab or at
command is run. This reduces the overhead of checking for
new or changed files at regularly scheduled intervals.

As cron never exits, it should be executed only once. This
is done routinely by way of the svc:/system/cron:default
service. The file /etc/cron.d/FIFO file is used as a lock
file to prevent the execution of more than one instance of
cron.

cron captures the output of the job's stdout and stderr
streams, and, if it is not empty, mails the output to the
user. If the job does not produce output, no mail is sent to
the user. An exception is if the job is an at(1) job and the
-m option was specified when the job was submitted.

cron and at jobs are not executed if your account is locked.
Jobs and processses execute. The shadow(4) file defines
which accounts are not locked and will have their jobs and
processes executed.

Setting cron Jobs Across Timezones
The timezone of the cron daemon sets the system-wide
timezone for cron entries. This, in turn, is by set by
default system-wide using /etc/default/init.

If some form of daylight savings or summer/winter time is in
effect, then jobs scheduled during the switchover period
could be executed once, twice, or not at all.

Setting cron Defaults
To keep a log of all actions taken by cron, you must specify
CRONLOG=YES in the /etc/default/cron file. If you specify
CRONLOG=NO, no logging is done. Keeping the log is a user
configurable option since cron usually creates huge log

SunOS 5.10 Last change: 5 Aug 2004 1
# 3  
Old 03-20-2005
Also have a look at the batch command if you're just submitting the odd job here and there....

Quote:
Originally Posted by man batch
Code:
batch   Executes commands when system load levels permit.  In other
        words, when the load average drops below 1.5, or the value speci-
        fied in the invocation of cron(8).

Cheers
ZB
# 4  
Old 03-20-2005
Thanks

Thanks everyone for the help. Its pretty obvious but im new to unix.
# 5  
Old 03-20-2005
You have to learn some how

That's fine, thats the whole point of community.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Activate command when computer is idle

I would like to run a command if my computer is idle. I found this, but is not quite working. #!/bin/sh idletime=$(xprintidle) threshold=300000 # 5 min = 5 * 60 * 1000 ms if ; then echo "idle for 5 minutes." fi (4 Replies)
Discussion started by: drew77
4 Replies

2. Shell Programming and Scripting

Run script when computer resume from being sleep state

I use this as a startup program. Is there a way that it could run when my computer returns from a sleep state? Cpu_LogFile="/home/andy/bin/CPU_Fan_Info.txt" date +"%Y-%m-%d-%H:%M:%S" >> $Cpu_LogFile sensors -f | grep "temp4" >> $Cpu_LogFile sensors -f | grep "fan1" >> $Cpu_LogFile (5 Replies)
Discussion started by: drew77
5 Replies

3. Windows & DOS: Issues & Discussions

How to run a Windows Setup on a Linux computer?

I am looking to run a Windows utility BitRecover PST Viewer. To help me read a pst file. Can anybody guide me how can I run this Windows utility on Linux. (3 Replies)
Discussion started by: marktux
3 Replies

4. Shell Programming and Scripting

Kill idle Process using a script

Hi, I need a script that can automatically kill all processes named "webrepn" and "webrebw" if idle for more than 30 minutes. Then I will have a Cron Job to run the script every night or 2-3 times a day depends on how this script helps. Right now, I run "ps -ef | grep webrebn" and "kill -9... (7 Replies)
Discussion started by: MaggieL
7 Replies

5. UNIX for Advanced & Expert Users

idle% cpu and run queue

Hi Everybody, Can anybody explain how CPU idle% is about 50%, but runq-sz more than 1? sar from Solaris 10: 00:00:05 %usr %sys %wio %idle 17:00:08 27 12 0 61 17:20:05 40 15 0 45 17:40:05 27 12 0 61 18:00:05 23... (2 Replies)
Discussion started by: sant
2 Replies

6. Shell Programming and Scripting

How to idle before executing a script

Hi I want to put a timer or whatever it could be ,a similar to sleep which will make the script to wait before executing it self like #!/bin/bash sleep 30 #or another comand which will wait 30 s. and than proceed with code but that timer should not freeze the OS . shell code ... (5 Replies)
Discussion started by: brain!ac
5 Replies

7. AIX

Kill IDLE Process using script !!!

Dear Friends , I am using DB2 database in AIX 5.3 server . In my server some IDLE process are generated after several times which I need to kill it manually each and every time . The process I query like following : root@bagpuss $ ps auxw|sort -r +3|head -10 USER PID %CPU %MEM ... (3 Replies)
Discussion started by: shipon_97
3 Replies

8. Shell Programming and Scripting

How to run a process when the computer is idle?

Hi there, I wrote a script that scans a folder for new files. I don't want to run it at specific times but only when the computer is NOT busy. I tried to use nice but it doesn't really work. I mean, even if my process has less priority, it still slows down the other processes. I did a test... (3 Replies)
Discussion started by: chebarbudo
3 Replies

9. UNIX for Dummies Questions & Answers

how can I run something as root (modprobe, to be exact) every time computer starts.

I have the root password for my box, but I'm ignorant. So, every time I start my computer, I have to run this command /sbin/modprobe fuse as su, so that I can do other stuff (like mount remote directories locally using sshfs) I guess there's some file, like .bashrc, only it's applicable... (4 Replies)
Discussion started by: tphyahoo
4 Replies

10. HP-UX

Is there a script available to kill Idle users

My max user parm is set to 1050. I'm currently at 1038 this is causing major slow downs on the server. I looking for a way log off "idle" user logins with out having to do it individually. :confused: (5 Replies)
Discussion started by: rfmurphy_6
5 Replies
Login or Register to Ask a Question