I write a shell script and installed it on systemctl to run on startup, everything works fine, however if i run "systemctl status myservice" it shows all my script source code instead only the outputs of my script my script looks similar to this (as a example):
while true
do
echo "pinging..."
ping -c 10 google.com
.... blah blah ....
.... blah blah ....
done
if i do systemctl status myservice it show my code instead "pinging..." and the ping output, how can i do that systemctl only shows the output instead the code?
Here is my systemctl status and systemctl cat outputs:
$systemctl status checkupserver:
● checkupserver.service - Check Servers Online Service
Loaded: loaded (/etc/systemd/system/checkupserver.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2022-05-09 20:54:21 UTC;
Main PID: 471544 (bash)
Tasks: 2 (limit: 9054)
Memory: 1.2M
CGroup: /system.slice/checkupserver.service
├─ 571033 /bin/checkservers.sh >
echo "Starting Service..."
while true
do
echo "pinging server..."
ping -c 10 serverip
... blah blah ...
done
/bin/checkservers.sh
└─4785411 /bin/checkservers.sh >
echo "Starting Service..."
while true
do
echo "pinging server..."
ping -c 10 serverip
... blah blah ...
done
/bin/checkservers.sh
$systemctl cat checkupserver:
# /etc/systemd/system/checkupserver.service
[Unit]
Description=Check Servers Online Service
[Service]
User=checker
ExecStart=/bin/checkservers.sh
Restart=always
RestartSec=10
TimeoutStopSec=90
KillMode=process
SyslogIdentifier=CheckServers
[Install]
WantedBy=multi-user.target