Skip to content

Commit a4e3dbb

Browse files
committed
iu
1 parent 1be8058 commit a4e3dbb

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env bash
2+
# Manages the script manage_my_process.
3+
# When passed the argument `start`:
4+
# 1. Starts manage_my_process
5+
# 2. Creates a file containings its PID in /var/run/my_process.pid
6+
# 3. Displays "manage_my_process started"
7+
# When passed the argument `stop`:
8+
# 1. Stops manage_my_process
9+
# 2. Deletes the file /var/run/my_process.pid
10+
# 3. Displays "manage_my_process stopped"
11+
# When passed the argument `restart`:
12+
# 1. Stops manage_my_process
13+
# 2. Deletes the file /var/run/my_process.pid
14+
# 3. Starts manage_my_process
15+
# 4. Creates a file containing its PID in /var/run/my_process.pid
16+
# 5. Displays "manage_my_process restarted"
17+
# If any other or no arguments are passed, displays
18+
#+ "Usage: manage_my_process {start|stop|restart}"
19+
20+
if [ "${1}" == "start" ]
21+
then
22+
./manage_my_process &
23+
touch /var/run/my_process.pid
24+
echo "$!" > /var/run/my_process.pid
25+
echo "manage_my_process started"
26+
elif [ "${1}" == "stop" ]
27+
then
28+
echo "manage_my_process stopped"
29+
kill "$(cat /var/run/my_process.pid)"
30+
rm /var/run/my_process.pid
31+
elif [ "${1}" == "restart" ]
32+
then
33+
kill "$(cat /var/run/my_process.pid)"
34+
rm /var/run/my_process.pid
35+
./manage_my_process &
36+
touch /var/run/my_process.pid
37+
echo "$!" > /var/run/my_process.pid
38+
echo "manage_my_process restarted"
39+
else
40+
echo "Usage: manage_my_process {start|stop|restart}"
41+
fi

0 commit comments

Comments
 (0)