Results 1 to 10 of 10
Hey there
I have come across a situation where I need a command to execute by itself after a period of time. Say for a simple example clear the screen ...
- 05-17-2009 #1
executing a command after a period of time
Hey there
I have come across a situation where I need a command to execute by itself after a period of time. Say for a simple example clear the screen after every 5 min ( as simple as that , but that's not wat i want to do lolz) . How do i accomplish that???Only if I could understand the man pages
Registered Linux user #492640
OS: RHEL4,5 ,RH 9,Ubuntu
- 05-17-2009 #2
Shedule commands for single execution: man at; man atd
Periodic execution: man crontabDebian GNU/Linux -- You know you want it.
- 05-18-2009 #3Banned
- Join Date
- Jun 2007
- Posts
- 4
What about a cron job? Those are rather easy to find info on setting up.... Google it !
- 05-18-2009 #4Linux Guru
- Join Date
- Nov 2007
- Location
- Córdoba (Spain)
- Posts
- 1,513
If you provide more details I might be able to give a more adequate response.
However, in bash you could do this with a simple loop, for example:
Code:while true; do echo foo; sleep 2; done
- 05-18-2009 #5
ok like i want to see the ppl who are logged on the tty after every five min.
Only if I could understand the man pages
Registered Linux user #492640
OS: RHEL4,5 ,RH 9,Ubuntu
- 05-18-2009 #6Linux Guru
- Join Date
- Nov 2007
- Location
- Córdoba (Spain)
- Posts
- 1,513
Then you could do something like this on a terminal:
Or if you preffer a fancy notification you could use:Code:while true; do users; sleep 2; done
OrCode:while true; do notify-send "$(users)"; sleep 5m; done
Code:while true; do users|osd_cat; sleep 5m; done
- 05-18-2009 #7
But every time i ll have to write the code manually. Is'nt there a way by which I can just tell bash to execute a script after some time.
Only if I could understand the man pages
Registered Linux user #492640
OS: RHEL4,5 ,RH 9,Ubuntu
- 05-18-2009 #8
try this.....
at now + 5 minutes < $HOME/listofcommands.txt
i googled it,, and i have to test.
i hope this will help u.
- 05-18-2009 #9Linux Guru
- Join Date
- Nov 2007
- Location
- Córdoba (Spain)
- Posts
- 1,513
That depends on your desktop and how do you start X. Most desktops have an autostart features, standalone wm's do have a config file which can usually launch whatever you want at start (some of them might have a graphical tool to configure this).
In kde you can drop any script you want to run at startup on ~/.kde/Autostart (at least in 3.x, I don't know about 4.x). No idea on how gnome do this, but I guess the place to look into is the session manager.
If you start X by hand with the startx command then you can put whatever you want to run in xinitrc, make sure you append an & at the end of the line so the command is backgrounded.
About the "at" command, it won't work for this purpose. "at" just schedules something to run at a later time, but it won't re-run it at regular intervals. At least not that I know of (though admittedly I haven't ever used it. I consider it to be useless, completely useless. You can just do "sleep 5m; whatever_command" instead.
- 05-18-2009 #10
how to do that in red hat 5
Only if I could understand the man pages
Registered Linux user #492640
OS: RHEL4,5 ,RH 9,Ubuntu


Reply With Quote
