LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-27-2012, 06:30 PM   #1
tonj
Member
 
Registered: Sep 2008
Posts: 419

Rep: Reputation: 24
translate keyboard stroke to terminal command


I need to schedule a command to run on a linux box (when I'm not there), but the command is CTRL + Q on the keyboard.
What's the correct syntax to make the terminal do this? I did a google search about this but could only find stuff about keyboard shortcuts when sitting at the computer. The reason I need this is because the only command I know to quit rtorrent is CTRL +Q and I need to terminate the program when I'm not around.
 
Old 09-27-2012, 06:37 PM   #2
odiseo77
Senior Member
 
Registered: Dec 2004
Location: Caracas, Venezuela
Distribution: Debian Sid, OpenSUSE 42.2
Posts: 1,177

Rep: Reputation: 592Reputation: 592Reputation: 592Reputation: 592Reputation: 592Reputation: 592
Have you tried the following?:

Code:
killall -9 rtorrent #or whatever the rtorrent process is named
(as you may guess, it will kill the rtorrent process).

Last edited by odiseo77; 09-27-2012 at 06:38 PM.
 
Old 09-28-2012, 03:52 AM   #3
tonj
Member
 
Registered: Sep 2008
Posts: 419

Original Poster
Rep: Reputation: 24
I was told once that one should only use killall -9 (on any process) as a last resort, and not as a normal stopping method. Being a newbie to this I don't know what's right or not. I'd still like to work out how to execute CTRL+Q if I can resolve that.
 
Old 09-28-2012, 03:42 PM   #4
linux_BSD
Member
 
Registered: Sep 2012
Posts: 47

Rep: Reputation: 4
Code:
pkill -P $(pgrep rtorrent)
This will kill the program rtorrent and it's child processes. You can also kill shell scripts that starts other programs and their processes.

Do a test run of the above command. If it works for you then you can use any of these commands crontab, at or sleep to schedule the execution.

Last edited by linux_BSD; 09-28-2012 at 06:22 PM.
 
Old 09-28-2012, 06:05 PM   #5
odiseo77
Senior Member
 
Registered: Dec 2004
Location: Caracas, Venezuela
Distribution: Debian Sid, OpenSUSE 42.2
Posts: 1,177

Rep: Reputation: 592Reputation: 592Reputation: 592Reputation: 592Reputation: 592Reputation: 592
I think this is what you're looking for. I'm not completely sure how it is done with killall, but since by default it sends a SIGTERM to the process, I guess the following will work (I'm not on a Linux machine at the moment to try):

Code:
killall rtorrent
(As far as I know, the SIGTERM signal doesn't really kill the process, but tells it to terminate by its own).

Or if you know the PID, you can use kill as explained in the link.

Last edited by odiseo77; 09-28-2012 at 06:06 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Translate this command equivalent for Mint? widda Linux - Newbie 8 02-15-2010 07:39 AM
BASH/No X: Using google translate to convert TXT files (translate) frenchn00b Programming 10 09-13-2009 10:55 PM
How The Unix OS translate the shell command flavor Programming 4 10-25-2005 12:02 PM
keyboard command: open gnome terminal daedalusq1115 Linux - Newbie 1 01-18-2005 03:29 PM
Key stroke/command to shut down x and go into the command prompt screen? Fear58 Linux - General 1 07-14-2004 07:14 PM


All times are GMT -5. The time now is 08:55 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration