Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I would like use kill with nohup function , I think it should use "kill -TERM" but if I want to also use kill level , for example "kill -8" , can advise how can I combine these function ? I tried "kill -TERM -8" is not work .
SIGHUP is the "hang-up" signal which is sent to children of login shells when the shell terminates. Think of the old set-up where a user logs into an old physical terminal like a vt100... each user is connected to the computer via a serial port. If the terminal device is turned off, or disconnects, the user is considered to be "hanging up" the serial line. That's the origin of the name anyhow.
Most programs will terminate if they receive SIGHUP (it is the default behaviour if the program does not explicitly handle the signal). By running with nohup, the nohup program traps the signal and ignores it, thus preventing the program from terminating.
SIGTERM (terminate) is an instruction to terminate a process. Think of it like a polite request for a program to close now. This gives the program a chance to terminate cleanly (e.g. if it's half way through some operation which it might want to finish first).
SIGINT (interrupt) is sent to a process when the user presses control-c (and the process is in the foreground in a terminal). Most applications close then they receive this signal.
The default behaviour for all these signals happens to be to terminate the program, but the program may choose to ignore the signal, or even trigger some other action instead of termination.
SIGKILL is a special in that a program cannot trap the signal - the process cannot avoid termination if it is sent SIGKILL - the OS just kills it immediately.
You may have noticed when you shut down in some distros you see a message something like "Shutting down... Sending TERM to all processes", then a short delay while the OS waits for all the processes to finish cleanly. There is then usually another message saying, "Sending KILL to all processes". This is the OS who, having waited patiently for programs to close doesn't ask nicely again - it just kills any remaining programs.
kill will never create new processes. probably you need to kill the parent process but I'm not really sure. nohup cannot protect any process against kill -9. processes can catch and tries to handle (ignore) some signals, like 1, 2 or 15, but not all of them.
Last edited by pan64; 05-21-2012 at 12:51 AM.
Reason: typo
implies you have the current dir '.' defined in your $PATH. This is generally considered a security risk, as someone could put a copy of an important prog eg rm into your current dir and it may take effect before the real one in eg /bin.
Normally you wouldn't have this; instead you'd use a path eg
Code:
nohup ./my-script.sh &
2. Your actual code looks odd; the '\'s are redundant. They are only used when you want to create a very long cmd line (eg 132 chars) and need to fold it eg so it can be seen in 80 chars.
Try
Code:
# Convert m4a to mp3
for i in *.m4a
do
ffmpeg -i "$i" -acodec libmp3lame -ac 2 -ab 192k "${i%m4a}mp3"
done
Your inability to stop this implies to me that you are actually trying to kill the ffmpeg process(es), not the pid of the script itself.
Normally
Code:
kill pid
is sufficient and sends the SIGTERM signal by default; see matthewg42's explanation above.
As he said, use 'kill -l' (lowercase L) to see all signals
Do NOT use -9 = SIGKILL if you can avoid it, as it kills the process without allowing it to clean up, which can lead to corrupt files.
Are you sure you're picking the right pid? My experience with nohup is limited, and i am not sure how it works, but you should be able to capture the pod with $! so you can later kill it
Code:
nohup <...>
pid=$!
...
.
.
kill -9$pid
But this really depends on what exactly your script is doing.
It is what chrism01 suggested. I foolishly did not detect the proper process id in grep. This allowed the true parent process id to continue re-spawning new 'ffmpeg' children.
TLDR - I am in the learning curve with 'nohup' - painfully so.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.