I have this simple bash script that looks like this:
#!/bin/sh
TIMESTAMP=`date "+%Y-%m-%d %H:%M:%S"`
echo "$TIMESTAMP restart" /etc/init.d/nginx restart > /usr/local/nginx/logs/restart.log 2>&1
It produces the output in my restart.log like this:
2020-04-17 18:22:30 Restarting nginx (via systemctl): nginx.service.
but the next time the script is run the output line is erased and there is just one line of the last restart instead of it. There is only one line all the time. It looks like it's just "one liner" script, not multiple lines.
Now the question is how do I make it keep all the previous entries like this:
2020-04-17 18:22:30 Restarting nginx (via systemctl): nginx.service.
2020-04-18 19:12:30 Restarting nginx (via systemctl): nginx.service.
2020-04-19 20:02:30 Restarting nginx (via systemctl): nginx.service.
I know it's supposed to be quite simple but I cannot figure it out. Would appreciate any comments / advices / suggestions. Many thanks in advance!