linux - BASH shell script works properly at command prompt but doesn't work with crontab -
here script want execute crontab.
#!/bin/bash # file of path /home/ksl7922/memory_test/run_process.sh # 'mlp' name of process, , 'ksl7922' user account. prgep mlp > /home/ksl7922/proc.txt # line give number of process of 'mlp' result=`sed -n '$=' /home/ksl7922/proc.txt` echo "result = ${result}" # if 'mlp' processes run less six, read text file 1 line , delete # it, , execute line. if ((result < 6)); filename="/home/ksl7922/memory_test/task_reserved.txt" cat $filename | while read line # delete line first. sed -i "$line/d" $filename # execute line eval $line break; done else echo "you're doing great." fi after that, editted crontab , checked crontab -l
*/20 * * * * sh /home/ksl7922/memory_test/run_process.sh this scripts works command line, however, doesn't work crontab.
it seems shell script works crontab anyway, because 'proc.txt' file generated, , first line of 'task_reserved.txt' removed.
however, didn't see messages, , result file of 'mlp' processes.
since i'm not @ english, i'm afraid guys don't understand intention. anyway, can let me know how handle this?
my bet
pathenvironment variable not correctly set withincron. insertecho $path > /tmp/cron-path.txtto see value has. perhaps need manually set proper value within script.
this faq
if don't have
mailinstallations on systemcronforward error messages script, it's practice manually redirect error messages preferred location. eg.#! /bin/bash { date prgep mlp > /home/ksl7922/proc.txt ... snip ... fi } &> /tmp/cron-msg.txt
Comments
Post a Comment