2

I have created a simple script to start a process, but I am not sure how to add a stop step since the process is ran/stopped manually

Currently, to start the process, we use a single command line

omrun dssdaemon <a string to run>

Then, to stop it, the usual ps command

ps -ef | grep -i dssdaemon

kill -9 <PID>

I have gotten this far

#!/bin/sh
# Priti's script to start dss daemon
pid=$(ps -ef | grep dssdaemon | grep -v grep | awk '{print $2}')
DSS_START=omrun dssdaemon <a string to run>

$DSS_START; sleep 15; echo "DSS Daemons is running with PID[S] below" && $pid

The process has some limitation with using pidof, that is why I have created the awk string instead.

I could really use some help with adding a status and kill step.

Something like this

# status dss daemon
DSS Daemon is running with PID[S] below
123456
432145

start dss daemon

DSS Daemon is started with PID[S] below 123456 432145

stop dss daemon

DSS Daemon with PID[S] below were killed 123456 432145

1 Answers1

3

Try to use killall or pkill tools. They do send a signal to the process just as kill does. But instead of pid, they look for the process by its name. And if you have several demons running - all of them would got the signal.

killall -9 dssdaemon
White Owl
  • 5,129