Jump to content

Ubuntu:Shut down application at a set time


Recommended Posts

Posted
Ive used scheduled tasks to start an application at a set time(in this case gimp), what would I need to do to automatically shut down an application at another set time?
Posted

so I guess I do

 

kill stop process-id

 

I know I can find the process-id for my running application under system monitor..processes but the process-id is going to change each time I run an application. How could I use kill to automatically close an app for example gimp without looking up its process-id first?

Posted

I find pkill useful for stopping non-responsive programs. Guess you're not bothered about saving if the'yre shutting down anyhow,

 

How about "pkill -9 gimp" You might need to pass it as a sudo command though. Tested here and it worked, Gimp just closed. No loss in system stability.

 

If you want to check the process name try

 

ps -u username

Posted

 

How about "pkill -9 gimp" You might need to pass it as a sudo command though.

 

You won't have to pass it throught sudo as long as the process your killing is running as the same username as the script.

Posted

Use killall and the "at" daemon. As root, ensure that atd is running ("ps ax | grep atd"). Then you can type something like:

 

at 23:17

 

You'll get a > prompt (iirc). You can type as many commands as you like here, pressing return at the end of each one. I tend to prepare these in advance and cut/paste since I find the backspace and arrow keys don't work well at the "at" prompt.

 

killall -9 someprogram

 

Press return. You could also do something like

 

poweroff

 

to shut down the whole PC at that time.

 

Press Ctrl-D to get to your usual prompt. Type "atq" to see the list of at jobs waiting to be run, and "atrm " to get rid of any you don't want.

 

HTH

 

--

Simon

 

BTW: I am a bad person and tend to be logged in as root. Whether or not you run your "at" commands as yourself or the root user depends on the amount of damage you're prepared to risk, but for me it's never been an issue.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...