I use the following commands to copy the entire directory to another server.
Sending server:
cd /var/log/ && tar c mysql > to_analyse.tar && nc 10.10.10.99 1236 < to_analyse.tar
Receiving server:
mkdir -p /var/log/splunk/from_217 && cd /var/log/splunk/from_217 && nc -l 1236 > to_analyse.tar && tar -xf to_analyse.tar
It is working as expected.
But when I add it to cron (copy paste with appropriate times), it does not work.
Best Answer
There are several things to check when using cron:
1- The user that is executing the cron job. This will affect the privileges assigned to the cron jobs.
2- The environment variables. Some scripts command may require some environment variables to work as expected.
3- It is better to refer to binaries/scripts using full path instead of just its name like
mkdir
andnc
. I am not saying it will not work. It may or may not depending on thePATH
definition and binary location.