I have a script that executes some commands remotely, every time it runs it appends the time of execution to a log. I thought I was doing it right but then realized the script was sending the time/date of my machine, not using the server time/date in the log.
This is the command I’m using right now:
ssh root@myserver "echo \"*** Log info of $(date -u) ***\" >> /var/log/app.log"
I tried using single quotes but it does not work at all the script shows an error.
Is there a better way to log that time to a file on the server?
Enclose the full command inside single quotes like this: