1

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.

Yeasir
  • 39
  • 1
  • 5
  • 1
    Something's different under `cron` then. Are all the binaries in the path? Try just output of `prtconf`, check if `awk` is available, etc. – Nikolai Fetissov Dec 23 '12 at 04:39
  • @NikolaiNFetissov: thanks a lot Nikolai. I found the clue from your answer. it's just that ***prtconf*** is not known to the cron. so i wrote the full path `/etc/prtconf` and that was it !!! Thanks a lot. – Yeasir Dec 23 '12 at 10:02
  • 2
    Better to use the real full path of `/usr/sbin/prtconf` instead of the obsolete symlink under `/etc` since the `/etc` symlink is removed in Solaris 11 and later releases. – alanc Dec 23 '12 at 18:26
  • thanks for the information @alanc . will check out this option as well. – Yeasir Jan 02 '13 at 04:09

0 Answers0