Sponsored Content
Top Forums Shell Programming and Scripting Activate command when computer is idle Post 303023793 by drew77 on Saturday 22nd of September 2018 03:50:56 PM
Old 09-22-2018
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.

Code:
#!/bin/sh
idletime=$(xprintidle)
threshold=300000 # 5 min = 5 * 60 * 1000 ms
if [ "$idletime" -gt "$threshold" ]; then
  echo "idle for 5 minutes."
fi


Last edited by Scott; 09-22-2018 at 04:53 PM.. Reason: Code tags
 

10 More Discussions You Might Find Interesting

1. Slackware

how to activate USB mouse

:confused: I am using Linux for a while and now changed to slackware for my study and it is not as good as redhat everytime when you add this or that it needs either configure modules or recompile kernel Now I changed from PS/2 mouse to USB trouble starts it refuse to work I know I can... (3 Replies)
Discussion started by: slackware
3 Replies

2. UNIX for Dummies Questions & Answers

how do i activate php on linux....

i have activated mysql, and apache on my redhat 9 box, i went to mr BASH and wrote a php script, and it wouldn't execute. any help????????????????????????????????????? is there something that i need to activate??????? i have RUBY on there too,does it matter or no??? ... (2 Replies)
Discussion started by: mbabeli
2 Replies

3. UNIX for Dummies Questions & Answers

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 :) (4 Replies)
Discussion started by: rehansaeed
4 Replies

4. UNIX for Advanced & Expert Users

activate and deactivate

hi all by using gethostbyname, i can know whether the net is available or not. it is working fine when i activate or deactivate in neat. the problem is when i remove cable(netcable) it is not working proparly, i would like to know it. am using fedora5, AMD can u please help me . thank... (3 Replies)
Discussion started by: munna_dude
3 Replies

5. IP Networking

How to activate a network interface?

What are the steps between "ifconfig eth0 UP" and "net_device->open"? ifconfig eth0 UP => ioctl(skfd, SIOCSIFFLAGS, &ifr) (ifr.ifr_flags = IFF_UP | IFF_RUNNING) => ????? => what are these steps? net_device->open Thanks! (1 Reply)
Discussion started by: samuncle
1 Replies

6. Red Hat

activate ftp from xinetd

Hello all, I´m trying to configure the ftp service (port 21) in a Red Hat Enterprise 4 from xinetd. Anybody have done this? Thank you in advance. (3 Replies)
Discussion started by: mig28mx
3 Replies

7. Solaris

Solaris user account de-activated, command to activate again

My admin has set password policy to de-activate user account if there is not login for 90 days. How can i re-activate user account w/o deleting, or changing user password. Thanks in advance Deeps (6 Replies)
Discussion started by: admin@solaris
6 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. Shell Programming and Scripting

How to get the information about cpu idle from top command?

I am using Ubuntu 9.04. I want to write a shell script to get the information about cpu idle from top command at the real time when i call it, compare cpu idle with 20 (20%), if cpu idle > 20 exit 1, vice versa exit 0. Anybody can help me to resolve it ? Thanks alot. (7 Replies)
Discussion started by: huyquocnguyen
7 Replies

10. UNIX for Beginners Questions & Answers

Idle command to kill the process running n unx box machine

Hi Team , I have one process named as cec_analysiseool that is running on unix box machine now i want to kill this process so please advise what will be the ideal command to kill this , what i have tried is :confused: kill -9 `ps -ef | grep cec_analysiseool | grep -v grep | awk '{print $2}'` (2 Replies)
Discussion started by: unclesamm
2 Replies
update(n)						       Tcl Built-In Commands							 update(n)

__________________________________________________________________________________________________________________________________________________

NAME
update - Process pending events and idle callbacks SYNOPSIS
update ?idletasks? _________________________________________________________________ DESCRIPTION
This command is used to bring the application "up to date" by entering the event loop repeatedly until all pending events (including idle callbacks) have been processed. If the idletasks keyword is specified as an argument to the command, then no new events or errors are processed; only idle callbacks are invoked. This causes operations that are normally deferred, such as display updates and window layout calculations, to be performed imme- diately. The update idletasks command is useful in scripts where changes have been made to the application's state and you want those changes to appear on the display immediately, rather than waiting for the script to complete. Most display updates are performed as idle callbacks, so update idletasks will cause them to run. However, there are some kinds of updates that only happen in response to events, such as those triggered by window size changes; these updates will not occur in update idletasks. The update command with no options is useful in scripts where you are performing a long-running computation but you still want the applica- tion to respond to events such as user interactions; if you occasionally call update then user input will be processed during the next call to update. EXAMPLE
Run computations for about a second and then finish: set x 1000 set done 0 after 1000 set done 1 while {!$done} { # A very silly example! set x [expr {log($x) ** 2.8}] # Test to see if our time-limit has been hit. This would # also give a chance for serving network sockets and, if # the Tk package is loaded, updating a user interface. update } SEE ALSO
after(n), interp(n) KEYWORDS
event, flush, handler, idle, update Tcl 7.5 update(n)
All times are GMT -4. The time now is 11:40 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy