3

Following is my crontab entry

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
* * * * *  /FinalSync.sh $(date --date="5 days ago" +%d_%m_%Y) || echo $? >> log

Got no error in log file also

Shell Script

#! /bin/sh

source=/Source/$1
destination=/Destination
folderParam=$(basename $source)
if /usr/bin/rsync -avh -r $source $destination; then
   cp /FolderCopyStatus/Success   /Status/Success_$folderParam
else
   cp /FolderCopyStatus/Failure   /Status/Failure_$folderParam
fi

Script run perfectly when I use in command line as under

sh /FinalSync.sh  $(date --date="5 days ago" +%d_%m_%Y)
HDev007
  • 261

1 Answers1

5

cron converts % to newline for any crontab entry. You need to escape the %s with \:

* * * * *  /FinalSync.sh "$(date --date="5 days ago" +\%d_\%m_\%Y)"
heemayl
  • 56,300