您当前的位置: 首页 >  慌途L Java

DataX踩坑2 | 定时任务crontab不执行或报错:/bin/sh: java: command not found

慌途L 发布时间:2020-10-29 10:11:19 ,浏览量:4

前面两天写了一个DataX的增量同步脚本,今天检查了一下发现定时任务没有执行成功,数据并没有同步。以下为排查问题和解决方法。

一、定时任务crontab不执行

脚本(测试用的可以设为每分钟一次:*/1 * * * *):

0 5 * * * /opt/datax/bin/incrSyncTask.sh >/dev/null 2>&1
1.查看crontab日志,看是否成功执行了脚本:
tail -f /var/log/cron

在这里插入图片描述

报错:

Oct 28 09:32:10 izwz9j58zzz42e5r70ct5oz crontab[18564]: (root) REPLACE (root) Oct 28 09:32:10 izwz9j58zzz42e5r70ct5oz crontab[18564]: (root) END EDIT (root) Oct 28 09:33:01 izwz9j58zzz42e5r70ct5oz crond[513]: (root) RELOAD (/var/spool/cron/root) Oct 28 09:33:01 izwz9j58zzz42e5r70ct5oz CROND[19639]: (root) CMD (/opt/datax/bin/incrSyncTask_prod.sh) Oct 28 09:33:01 izwz9j58zzz42e5r70ct5oz CROND[19638]: (root) MAIL (mailed 191 bytes of output but got status 0x004b#012)

这里表示发送邮件到mail邮箱失败,要重新配置,查看第三步 2.查看mail邮箱日志
tail -f /var/log/maillog

在这里插入图片描述 还是报错: sendmail: fatal: parameter inet_interfaces: no local interface found for ::1

3.解决方法

修改/etc/postfix/main.cf文件中的inet_interfaces参数inet_interfaces = all即可

vim /etc/postfix/main.cf

下面是原来默认的值: 在这里插入图片描述

修改保存后,就可以看到定时任务不会报错了 二、crontab定时任务执行Shell脚本报错:/bin/sh: java: command not found 报错:/bin/sh: java: command not found 解决方法:

在shell脚本中加入下面的参数即可:

. /etc/profile

在这里插入图片描述

加入后定时任务就可以正常的运行shell脚本了。 相关文章
  • DataX | 在Liunx上安装和使用.
  • DataX | MySQL多表全量同步和多表定时增量同步.
  • DataX踩坑1 | 连接数据库失败. 请检查您的 账号、密码、数据库名称、IP、Port.
  • Shell 脚本参数传递时有 \r 换行符问题.
关注
打赏
1688896170
查看更多评论

慌途L

暂无认证

  • 4浏览

    0关注

    118博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文
立即登录/注册

微信扫码登录

0.0479s