Time and date stamps in cron?
I'm trying to create a cron job to periodically log the output of 'netstat -m' with a timestamp, but I'm not sure how to create the timestamp. So I'm thinking of a command something like this
echo "$date $time `netstat -m` >> /var/log/netstat-m.log
but I don't know how to produce current values for $date and $time. Help?
Also, some tips on formatting the output would be good, like how to insert a line break after the output. Thanks.
Make sure you use the full path to every command in a cron entry, and no need to involve echo:
/bin/date >> /var/log/netstat-m.log; /usr/bin/netstat -m >> /var/log/netstat-m.log
One more thing, does that directory survive reboots?
On a full install, yes. On nanobsd, no.