Sponsored Content
Top Forums UNIX for Dummies Questions & Answers How to run a script when your computer is idle Post 66995 by chek on Saturday 19th of March 2005 10:30:44 PM
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
 

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
cron(8) 						      System Manager's Manual							   cron(8)

NAME
cron - The system clock daemon SYNOPSIS
/usr/sbin/cron DESCRIPTION
The cron daemon runs shell commands at specified dates and times. Commands that are to run according to a regular or periodic schedule are found within the crontab files. Commands that are to run once only are found within the at files. You submit crontab and at file entries by using the crontab and at commands. Because the cron process exits only when killed or when the system stops, only one cron daemon should exist on the system at any given time. Normally, you start the cron daemon from within a run command file. During process initialization and when cron detects a change, it examines the crontab and at files. This strategy reduces the overhead of checking for new or changed files at regularly scheduled intervals. The cron command creates a log of its activities. The cron daemon must be started from the system startup scripts because it must begin execution without a login user ID set. The cron daemon starts each job with the following process attributes stored with the job by the invoking process: Login user ID Effective and real user IDs Effective and real group IDs Supplementary groups It also establishes the following attributes from the authentication profile of the account associated with the login user ID of the invok- ing process: Audit control and disposition masks Kernel authorizations DIAGNOSTICS
The at and batch programs will refuse to accept jobs submitted from processes whose login user ID is different from the real user ID. FILES
Specifies the command path. Main cron directory Directory containing the crontab files. List of allowed users. List of denied users His- tory information for cron Queue description file for at, batch, and cron RELATED INFORMATION
Commands: at(1), crontab(1), rc0(8), rc2(8), rc3(8) Files: queuedefs(4) delim off cron(8)
All times are GMT -4. The time now is 06:02 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy