I have the below commands which is running properly on the local machine.
watch -t -n1 "echo `date '+%Y-%m-%d %H:%M:%S'` | tee -a Time.txt" &>/dev/null &
But when I run it from the remote machine I won't create the expected output i.e. Time.txt is not created and will not be running as a background process.
ssh ipaddress watch -t -n1 "echo `date '+%Y-%m-%d %H:%M:%S'` | tee -a Time.txt" &>/dev/null &
Please help me on this. I have tried multiple options like putting ', " for watch command but it did not helped me out.
echo
to output the result of a sub shell.tee
to append to a file.watch
to sleep for one second.Try this instead.
ssh -t ipaddress 'while sleep 1; do date +%Y-%m-%d\ %H:%M:%S >> Time.txt; done &'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With