I have simple batch script in linux debian – Debian GNU/Linux 6.0 – that stop process then deletes log files and start the process again :
#!/bin/bash
killall -KILL rsyslogd
sleep 5s
rm /var/log/syslog
rm /var/log/messages
rm /var/log/kern.log
sleep 3s
rsyslogd
exit
The process name is rsyslogd. I have to close it before deleting the log files, for linux to empty the space from disk.
I see that killall -KILL closes the process by its name, but what is the opposite – the run command?
Calling it by its name without any command seems to not work. I will be glad for any tips, thank you.
2
Answers
Debian uses
systemd
to manage processes. You should, therefore, use the systemd’s commands to stop and startrsyslogd
.and
If you are using really old versions of Debian (so old that you should upgrade), it may be possible that sys V is still used. In that case, there is a file under
/etc/init.d
which is calledrc.rsyslog
or something comparable (usels /etc/init.d
to find the exact name). In that case, it would beand
Or it may be, that your
systemd
-package may be broken. In that case, the package can be re-installed:To start rsyslogd:
To stop it:
If you want to do both, use