0

I have written a short script to upload a log to my ftp server, you can ignore everything apart from the last line which is supposed to restart rsyslog. Executing the command from the command line works fine but it doesn't work in the script file. Can anybody help ?

#!/bin/bash


mv /var/log/rtx8660.log /home/vocovo/RTX8660_$(date +"%Y-%m-%d-%H_%M").log

touch /var/log/rtx8660.log

 cd /home/vocovo


  FTPLOG=/tmp/ftplogfile
  ftp -inv <<! > $FTPLOG
  open SERVER
  user USER PASS
  cd /Wickes_Test
  prompt
  mput RTX*
  close
  quit
  !

 FTP_SUCCESS_MSG="226 Transfer complete"
 if fgrep "$FTP_SUCCESS_MSG" $FTPLOG ;then
 echo "ftp OK"
 rm RTX*
 else
 echo "ftp Error: "$OUT
 fi
 exit 0




 service rsyslog restart
  • 1
    What's the error message you see? – Wieland Dec 9 '16 at 15:47
3

The last line is never executed because you exit the script just before it.

exit 0

must be the last line of your script.

0

You didn't mention which Debian version, but assuming you're using one relayed on init.d, you can try:

/etc/init.d/rsyslog restart

Remember to run as root.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.