skip to Main Content

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


  1. Debian uses systemd to manage processes. You should, therefore, use the systemd’s commands to stop and start rsyslogd.

    systemctl stop rsyslog
    

    and

    systemctl start rsyslog
    

    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 called rc.rsyslog or something comparable (use ls /etc/init.d to find the exact name). In that case, it would be

    sudo /etc/init.d/rc.rsyslog stop
    

    and

    sudo /etc/init.d/rc.rsyslog start
    

    Or it may be, that your systemd-package may be broken. In that case, the package can be re-installed:

    apt-get --reinstall install systemd
    
    Login or Signup to reply.
  2. To start rsyslogd:

     systemctl start rsyslog
    

    To stop it:

     systemctl stop rsyslog
    

    If you want to do both, use

     systemctl restart rsyslog
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search