I am facing a weired problem. its been 2 days i tried so many things but to no success.
On sun solaris i have written a script that will check for the total physical memory of the system, then assign it to a variable and then write the value to a file. Now when i run the script manually the variable is correctly written to the file. but if i put the script on cron, nothing happens. the file is created ok, but no value is written on it. I have tried printf and echo, both working if run from prompt but not working from cron. Printf writes nothing to file, echo writes blank line. below is the snippet:
#!/bin/bash
total_mem=`prtconf | head -3 |grep Mem | awk -F" " '{print $3}'`
printf $total_mem >> test.txt
####i have tried echo as well
#/usr/bin/echo $total_mem >> test.txt
please help.