Centos – Why unison does not run in cronjob

centoscronsynchronizationunison

I want two way data sync between two CentOS based servers, so I installed Unison on both of my CentOS servers. I made a script file on root which runs unison and works fine, and syncs the files, when I run it from terminal. When I put that script in the crontab the sync simply does not work.
My /etc/crontab is

*/1  *  *  *  * root sh /root/syncaaa.sh &>/root/unison-cron.log

And what crontab puts in the /root/unison-cron.log

Usage: unison [options]
    or unison root1 root2 [options]
    or unison profilename [options]

For a list of options, type "unison -help".
For a tutorial on basic usage, type "unison -doc tutorial".
For other documentation, type "unison -doc topics".

My unison.log file does not updated when run via cron, but only updates when runs directly via terminal. I checked in cron logs and syncaaa.sh file runs every miunte.
Can anyone suggest me what I should do to debug it?

Note: My server 1 can login to server 2 without password, as I have
set rsa keys in server2 authorized_keys.

> Update 1: I tried set -x in the script and it printed

+ chmod -R 0777 /home/user11/folder/
+ /usr/bin/unison
Usage: unison [options]
    or unison root1 root2 [options]
    or unison profilename [options]

For a list of options, type "unison -help".
For a tutorial on basic usage, type "unison -doc tutorial".
For other documentation, type "unison -doc topics"

and /usr/bin/unison command works fine on terminal

Best Answer

I solved the problem, and it was the HOME=/ in crontab, it should be the path where your .unison exists

So my crontab content now is

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/home/user1/

# For details see man 4 crontabs

# Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  * user-name command to be executed
*/1  *  *  *  * user1 sh syncaaa.sh &>unison-cron.log