I am new in writing shell script i write a script like this
#!/bin/bash
PID=$(ps -ef | grep "sh gps.sh" | grep -v grep | awk '{print $2}')
if [ -z $PID ]
then
cd /opt/etrans/cronjobs
cnt=$(echo "select 'count '||count(*) from schema.table where c_is_processed ='N'" | psql | grep count |awk '{print $2}')
echo "Out side of if count is $cnt" | cat >> /opt/cronlog/unprocess_data_process.log # for log writing
if [ $cnt -ge 5000 ]
then
echo "Inside manual gps" | cat >> /opt/cronlog/unprocess_data_process.log # for log writing
sh manual_gps.sh
else
echo "Inside gps" | cat >> /opt/cronlog/unprocess_data_process.log # for log writing
sh gps.sh
fi
else
echo "gps Process is Running with PID=$PID"
fi
exit
when I run the .sh file manually it runs file and I can see all the counts in my log file but when I run it from crontab it is not printing the counts.