title: How to stop script from sending mails?
body: <p>OS: Raspbian Lite Kernel version:4.19</p>
  
  <p>I am using a script to monitor a service, so that it would start the service if it goes down. I have added it in <code>crontab</code> and it does a great job. The only problem is that it sends its output to <code>/var/mail/pi</code> : <code>You have new mail in /var/mail/pi</code>.</p>
  
  <p>I am afraid that the file will grow too large or that at some point in time it will stop working because of this.</p>
  
  <p>I have found the script online and I don't know what to modify so that it won't send mails:</p>
  
  <pre><code># vi /var/www/html/service_monitor.sh
  
  #!/bin/bash
  
  serv=DisplayM
  
  sstat=dead
  
  systemctl status $serv | grep -i 'running\|dead' | awk '{print $3}' | sed 's/[()]//g' | while read output;
  
  do
  
  echo $output
  
  if [ "$output" == "$sstat" ]; then
  
      sudo systemctl start $serv
  
      echo "$serv service is now UP !" | echo "$serv service was DOWN. Restarting now on $(hostname)"
  
      else
  
      echo "$serv service is running"
  
      fi
  
  done
  </code></pre>
  
  <p>These can act like some sort of logs, so I wouldn't mind keeping the <code>/var/mail/pi</code> file, but it would be nice do keep like, the last 100 entries and delete the others.</p>
  
  <p>What do you think ?</p>