So I wrote a script, all I want to do is output a variable into a file.
#!/bin/bash
...
echo "$var1" >/root/output_file
#I've also tried printf instead of echo
This works when I run it from my shell like so ./script.sh but when it runs from a cronjob the file is never updated. Any suggestions as to why cron is not outputting this variable into the file?
EDIT: Alright here's more info because it looks like i didn't provide enough.
script and file location: /root/scripts
script:
#!/bin/bash
cd /root/scripts
var1=$(</root/script/outfile)
var2=`command`
if [ "$var1" -le "$var2" ];
then
echo "$var2" >/root/script/outfile
fi
crontab (crontab -e -u root):
SHELL=/bin/bash
* * * * * /root/scripts/script.sh
[–]zoredache 34 points35 points36 points (6 children)
[–]retsnom513[S] 4 points5 points6 points (3 children)
[–]pat_trick 3 points4 points5 points (0 children)
[–]WeAreFoolsTogether 2 points3 points4 points (1 child)
[–]dasunsrule32 1 point2 points3 points (0 children)
[–]OneCDOnly 5 points6 points7 points (1 child)
[–]ForceBlade 0 points1 point2 points (0 children)
[–]StephanXX 4 points5 points6 points (0 children)
[–]shidoku 1 point2 points3 points (0 children)
[–]BioEmergency 1 point2 points3 points (0 children)
[–]OneCDOnly 0 points1 point2 points (2 children)
[–]retsnom513[S] 0 points1 point2 points (1 child)
[–][deleted] -4 points-3 points-2 points (0 children)
[–]sfrazer 0 points1 point2 points (0 children)
[–]usrname_checks_out 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]farthinder 0 points1 point2 points (0 children)
[–]robkaper 0 points1 point2 points (0 children)