使用 Cron 安排的作业未执行
我已经计划执行job.sh脚本,其中包含以下命令:
date +"%D %r `echo Kitchen - job started`" >> /tmp/cron_job_1.log
sh /installations/data-integration/kitchen.sh -file /installations/etl/sync_job.kjb >> /tmp/cron_job_1.log
date +"%D %r `echo Kitchen - job completed`" >> /tmp/cron_job_1.log
Crontab记录是:
0,3,4,5,6,8,10,11 * * * * sh /installations/etl_scripts/job.sh
“作业开始”和“作业完成”时间戳总是成功写入cron_job_1.log,这是计划作业按时运行的证明。但似乎 Pentaho 转换(../kitchen.sh)命令没有运行,因为转换没有进行,并且没有任何内容写入日志文件。 “作业开始”和“作业结束”之间的时间为 1 或 2 秒,但转换作业应至少运行 10 秒。
当我运行命令 sh /installations/data-integration/kitchen.sh -file /installations/etl/sync_job.kjb >>> /tmp/cron_job_1.log
独立于控制台转换作业按预期工作并写入日志。
涉及文件的所有路径和权限似乎都是正确的。
有什么建议吗?
I've scheduled to execute job.sh script, which contains the following commands:
date +"%D %r `echo Kitchen - job started`" >> /tmp/cron_job_1.log
sh /installations/data-integration/kitchen.sh -file /installations/etl/sync_job.kjb >> /tmp/cron_job_1.log
date +"%D %r `echo Kitchen - job completed`" >> /tmp/cron_job_1.log
Crontab record is:
0,3,4,5,6,8,10,11 * * * * sh /installations/etl_scripts/job.sh
'Job started' and 'job completed' timestamps are always successfully written to cron_job_1.log, it's a proof that scheduled job runs on time. But it seems that Pentaho transformation (../kitchen.sh) command does not run, because transformation does not proceeding and nothing is written to log file. Time between 'job started' and 'job ended' is 1 or 2 seconds, but transformation job should run at least 10 seconds.
When i run command sh /installations/data-integration/kitchen.sh -file /installations/etl/sync_job.kjb >> /tmp/cron_job_1.log
independently from console transformation job works as expected and writes to log.
All paths and permissions of involved files seems to be correct.
Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据 crontab FAQ : cron 仅设置稀疏环境,因此您的环境变量无法在 cron 脚本中访问。您必须在 job.sh 脚本中设置环境变量。
According to crontab FAQ : cron sets up only a sparse environment, so your environment variables are not accessible in cron script. You have to set up environment variables in your job.sh script.