When i run this shell script manually on a Linux terminal by executing "./filename.sh" at the 12th hour (or any hour i specify). it works perfectly. it follows the IF condition perfectly
But when i use a cronjob to automate this script, for some reason, it never picks up the first part of the IF condition. it echoes "Not working" even while still being in the 12th hour.
i can't get to figure out what the problem is
Running on an Ubuntu 20.04 server.
Note: i edited the cronjob to run every 5mins while i troubleshoot . Here's the cronjob
*/5 * * * * /bin/sh /home/user/filenam.sh
#!/bin/bash
HOURID=`(date '+%H')`
if [[ $HOURID == 12 ]];
then
echo "It works" > a.txt
else
echo "Not working" > a.txt
fi