Script not getting executed via cron but executes when executed manually.

Hi

Script not getting executed via cron but executes successfully when executed manually. Please assist

cbspsap01(appuser) /app/scripts > cat restart.sh
#!/bin/ksh
cd /app/bin
date >>logfile.out
echo "Restart has been started....." >>logfile.out
date >>logfile.out
initfnsw -y restart >>logfile.out
date >>logfile.out
echo "Restart has been completed...." >>logfile.out
date >>logfile.out
---------------------------------------------------------
cbspsap01(appuser)/app/scripts> crontab -l
30 3 * * * /app/scripts/restart.sh > /dev/null 2>&1
---------------------------------------------------------

try this

1 Like

Also, when you reference files like "logfile.out", be sure to use a relative path, like "./logfile.out", or a fully qualified path, like "/app/bin/logfile.out". That is just good scripting practice.

1 Like

Its solved :

30 3 * * * SHELL=/usr/bin/ksh; export SHELL; . $HOME/.profile; ksh /app/scripts/restart.sh > /dev/null 2>&1