Sponsored Content
Top Forums Shell Programming and Scripting script killing a process from service status output Post 302688667 by alister on Sunday 19th of August 2012 10:51:28 PM
Old 08-19-2012
You both seem to be having issues figuring out how to handle shell quoting.

To pass a single-quote when using a single-quoted string, you need to close the string, escape the single-quote, then re-open the string. In short, for each ' you need to pass, use '\''.

Example:
echo '>>'\''<<' prints >>'<<.

For the double-quoted equivlalent, simply backslash-escape the double-quote within the double-quoted string.

Finally, don't use `...`; it's an obsolete, deprecated, and troublesome form of command substitution. Instead, use $(...).

Regards,
Alister
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

killing process using a script

can I do ps -ef | grep <process_name> and kill the process is it exists? and send a mail to me that the process was found and killed Thanks much... KS (4 Replies)
Discussion started by: skotapal
4 Replies

2. Shell Programming and Scripting

Killing a process from perl script.

How do I kill a process, say by name "drec" from a perl script. I tried with : ps -eaf | grep drec | awk '{print $2}' | xargs kill -9. The output I got is : ps -eaf | grep drec | awk '{print }' | xargs kill -9 /usr/bin/kill: ipgen: Arguments must be %job or process ids {But, $2 is not... (3 Replies)
Discussion started by: sharuvman
3 Replies

3. AIX

killing a process from a script

Hey all. I'm brand new to this forum and am looking for some help. I have a script that verifies that the backup tapes are working correctly. Basically is uses 1 command: restore -xpqvf > rootvglog I use this for each volume group that we have. We run this everyday but the problem is, we... (4 Replies)
Discussion started by: jalge2
4 Replies

4. Shell Programming and Scripting

While killing the process, Script gets hanged. Please help me on this.

Hi Everyone, I have written a script to automate the docbase cleanup process on every weekly basis. That is in this script i have to shutdown the docbase and then kill all the process that are hanged except one process(epic process) and need to delete some log files and then i have to start the... (8 Replies)
Discussion started by: Sheethal
8 Replies

5. Linux

Ftp Service /process Status

:confused: Hi Can anyone tell me how to check the FTP process status in linux . eg,I'm ftpping some files from "A" server to "B" server through FTP command , after ftpping these files , I 'm suppose to delete the files which are successfully ftpped from "A" server ,but when I 'm checking the... (1 Reply)
Discussion started by: GaneshB
1 Replies

6. Shell Programming and Scripting

script not killing process!

i am using script to connect remotly to server and run some commands , one of these commands is to kill some process but tried different ways with no hope sshpass -p 'pass' ssh -o StrictHostKeyChecking=no server kill -9 `pgrep procs` getting error message "kill: bad argument count" ... (2 Replies)
Discussion started by: mogabr
2 Replies

7. Shell Programming and Scripting

**need help for killing a process through script**

Hello All, i hope you are fine. I need a little help from you people-- inside a script i want to kill a parent process by checking it with the child process.. p_pid=`ps -e | awk '/ra_cmd_d/ {print$1}'` here i am selecting the child process id in p_pid. next-- sleep_pid=`ps -af |... (3 Replies)
Discussion started by: onlyniladri
3 Replies

8. Shell Programming and Scripting

Output when killing a background process

I played a bit around with the Terminal and I observed something. When I start and kill a background process, there is some kind of output. After I invoked the command to start the process the first message " 13063" is directly displayed. However, after killing the process, the second message "+... (3 Replies)
Discussion started by: Chuck Morris
3 Replies

9. Shell Programming and Scripting

Killing a bash process and running the second part of script

I want to run a script that calls remote ssh and if it gets hung, I want to be able to kill that part of the script and run another command in the script for example I have a statement like this: if ]; then export tapes=$(for tape in $(su - nacct -c 'ssh remote1 "cat... (1 Reply)
Discussion started by: newbie2010
1 Replies

10. Shell Programming and Scripting

Automated Script for Process killing

Hello all, I'm in need of a Script which needs to wait for all the child process to end and then kill the main process. I have a process called mainpp which runs for different instances like evpn, nge, gmn etc so when i query for mainpp process it looks like below. bash-3.2$ ps -eaf |... (6 Replies)
Discussion started by: Mahesh_RPM
6 Replies
SYSTEMD.KILL(5) 						   systemd.kill 						   SYSTEMD.KILL(5)

NAME
systemd.kill - Process killing procedure configuration SYNOPSIS
service.service, socket.socket, mount.mount, swap.swap, scope.scope DESCRIPTION
Unit configuration files for services, sockets, mount points, swap devices and scopes share a subset of configuration options which define the killing procedure of processes belonging to the unit. This man page lists the configuration options shared by these five unit types. See systemd.unit(5) for the common options shared by all unit configuration files, and systemd.service(5), systemd.socket(5), systemd.swap(5), systemd.mount(5) and systemd.scope(5) for more information on the configuration file options specific to each unit type. The kill procedure configuration options are configured in the [Service], [Socket], [Mount] or [Swap] section, depending on the unit type. OPTIONS
KillMode= Specifies how processes of this unit shall be killed. One of control-group, process, mixed, none. If set to control-group, all remaining processes in the control group of this unit will be killed on unit stop (for services: after the stop command is executed, as configured with ExecStop=). If set to process, only the main process itself is killed. If set to mixed, the SIGTERM signal (see below) is sent to the main process while the subsequent SIGKILL signal (see below) is sent to all remaining processes of the unit's control group. If set to none, no process is killed. In this case, only the stop command will be executed on unit stop, but no process be killed otherwise. Processes remaining alive after stop are left in their control group and the control group continues to exist after stop unless it is empty. Processes will first be terminated via SIGTERM (unless the signal to send is changed via KillSignal=). Optionally, this is immediately followed by a SIGHUP (if enabled with SendSIGHUP=). If then, after a delay (configured via the TimeoutStopSec= option), processes still remain, the termination request is repeated with the SIGKILL signal (unless this is disabled via the SendSIGKILL= option). See kill(2) for more information. Defaults to control-group. KillSignal= Specifies which signal to use when killing a service. This controls the signal that is sent as first step of shutting down a unit (see above), and is usually followed by SIGKILL (see above and below). For a list of valid signals, see signal(7). Defaults to SIGTERM. Note that, right after sending the signal specified in this setting, systemd will always send SIGCONT, to ensure that even suspended tasks can be terminated cleanly. SendSIGHUP= Specifies whether to send SIGHUP to remaining processes immediately after sending the signal configured with KillSignal=. This is useful to indicate to shells and shell-like programs that their connection has been severed. Takes a boolean value. Defaults to "no". SendSIGKILL= Specifies whether to send SIGKILL to remaining processes after a timeout, if the normal shutdown procedure left processes of the service around. Takes a boolean value. Defaults to "yes". SEE ALSO
systemd(1), systemctl(1), journalctl(8), systemd.unit(5), systemd.service(5), systemd.socket(5), systemd.swap(5), systemd.mount(5), systemd.exec(5), systemd.directives(7), kill(2), signal(7) systemd 237 SYSTEMD.KILL(5)
All times are GMT -4. The time now is 06:37 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy