这是我想用crontab执行的脚本。BASH shell脚本在命令提示符下正常工作,但不能用于crontab
#!/bin/bash
# File of the path is /home/ksl7922/Memory_test/run_process.sh
# 'mlp' is the name of the process, and 'ksl7922' is my user account.
prgep mlp > /home/ksl7922/proc.txt
# This line will give the number of the process of 'mlp'
result=`sed -n '$=' /home/ksl7922/proc.txt`
echo "result = ${result}"
# if 'mlp' processes run less than six, than read text file one line and delete
# it, and execute this line.
if ((result < 6)); then
filename="/home/ksl7922/Memory_test/task_reserved.txt"
cat $filename | while read LINE
do
# Delete line first.
sed -i "$LINE/d" $filename
# Execute this line
eval $LINE
break;
done
else
echo "You're doing great."
fi
在那之后,我editted crontab中,并用crontab的检查-l
*/20 * * * * sh /home/ksl7922/Memory_test/run_process.sh
该脚本正常工作的命令行,但是,它不能正常使用crontab的工作。
无论如何,shell脚本似乎可以与crontab协同工作,因为生成了'proc.txt'文件,并且'task_reserved.txt'的第一行被删除。
但是,我没有看到任何消息,以及'mlp'进程的结果文件。
因为我不擅长英语,所以恐怕你们不明白我的意图。 无论如何,任何人都可以让我知道如何处理这个?
提供'mlp'过程的绝对路径。 – devnull
什么是'prgep'?你的意思是'pgrep'? – ooga