前面两天写了一个DataX的增量同步脚本,今天检查了一下发现定时任务没有执行成功,数据并没有同步。以下为排查问题和解决方法。
一、定时任务crontab不执行
脚本(测试用的可以设为每分钟一次:*/1 * * * *
):
0 5 * * * /opt/datax/bin/incrSyncTask.sh >/dev/null 2>&1
1.查看crontab日志,看是否成功执行了脚本:
tail -f /var/log/cron
![在这里插入图片描述](https://img-blog.csdnimg.cn/2020102809500259.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzI1MTEyNTIz,size_16,color_FFFFFF,t_70#pic_center)
报错:
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
![在这里插入图片描述](https://img-blog.csdnimg.cn/20201028094624217.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzI1MTEyNTIz,size_16,color_FFFFFF,t_70#pic_center)
还是报错:
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
下面是原来默认的值:
![在这里插入图片描述](https://img-blog.csdnimg.cn/20201028094548943.png#pic_center)
修改保存后,就可以看到定时任务不会报错了
二、crontab定时任务执行Shell脚本报错:/bin/sh: java: command not found
报错:/bin/sh: java: command not found
解决方法:
在shell脚本中加入下面的参数即可:
. /etc/profile
![在这里插入图片描述](https://img-blog.csdnimg.cn/20201028115225381.png#)
加入后定时任务就可以正常的运行shell脚本了。
相关文章
- DataX | 在Liunx上安装和使用.
- DataX | MySQL多表全量同步和多表定时增量同步.
- DataX踩坑1 | 连接数据库失败. 请检查您的 账号、密码、数据库名称、IP、Port.
- Shell 脚本参数传递时有 \r 换行符问题.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)