I am facing issue with script execution in cron. Same script working fine on terminal and cron under bash version 4.3. But cron is failing for lower bash version.
I want to save command output in file in script like
#!/bin/bash
newendcount=$(/bin/cat error_files.log | wc -l)
echo $newendcount > /tmp/var.txt
with terminal it is working fine but with cron it not storing line count value, instead giving 0 as result. But same script working properly on terminal.
cronjob is like
* * * * * /bin/bash script.sh > /tmp/output.txt
I editing this question. As I got a solution to my issue. it was because of environment variable mismatch. I have added a line " . /root/.profile " at top of script and now cron is working as expected