[英]Variables are not returning values when called from crontab
When I call my script from crontab the variables are not returning any values. 当我从crontab调用脚本时,变量未返回任何值。 Whereas when I execute it manually (command line) it works fine.
而当我手动执行它(命令行)时,它可以正常工作。 I also observed only the $start_time and $end_time are not returning values whereas the $auto_job_name returns "mytext".
我还观察到只有$ start_time和$ end_time不返回值,而$ auto_job_name返回“ mytext”。 Could you please help on this?
您能帮上忙吗?
Contents of my script. 我的脚本的内容。
#!/bin/bash
auto_job_name="mytext"
start_time=`grep $auto_job_name job_status.txt`
end_time=`grep $auto_job_name job_status.txt`
echo $auto_job_name
echo $start_time
echo $end_time
You might write the absolute path to your job_status.txt file, for example: 您可以将绝对路径写入到job_status.txt文件,例如:
#!/bin/bash
auto_job_name="mytext"
start_time=`grep $auto_job_name /path/to/job_status.txt`
end_time=`grep $auto_job_name /path/to/job_status.txt`
echo $auto_job_name
echo $start_time
echo $end_time
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.