Linux执行crontab脚本出错
来源:互联网 发布:windjview mac版 编辑:程序博客网 时间:2024/06/08 07:33
Linux下用crontab执行定时任务不会缺省的从用户profile文件中读取环境变量参数,经常导致在手工执行某个 脚本时是成功的,但是到crontab中试图让它定期执行时就是会出错。
这是因为用户登陆Linux操作系统的时候,”/etc/profile”, “~/.bash_profile”等配置文件会被自动执行。2种方法可以解决这个问题,
1、在Shell文件里面获取环境变量值的路径写成绝对路径,别用环境变量的路径值。例如获取CPU的使用情况 通过绝对路径/proc/cpuinfo 来获取值;
2、Shell脚本缺省的#!/bin/bash开头换行后的第一行用
#!/bin/bash
. /etc/profile
. ~/.bash_profile
这样,crontab在执行脚本的时候,就能够读到用户的环境变量参数.
0 0
- Linux执行crontab脚本出错
- Linux定时任务crontab执行脚本出错
- linux直接执行shell脚本正常,使用定时任务crontab执行出错
- linux crontab 定时执行脚本
- 脚本手动执行无误,crontab自动执行出错
- crontab中脚本执行出错,无法重启服务
- Linux 定时执行任务 php脚本 crontab
- linux 定时执行shell脚本 crontab
- linux crontab 无法执行shell脚本解决方法
- Linux,crontab服务定时执行备份脚本
- Crontab 让linux定时执行shell脚本
- Linux下定时执行脚本/crontab
- crontab命令 :Linux下定时执行脚本
- Linux下crontab定时执行脚本
- linux crontab 定时执行php脚本
- Linux crontab定时执行PHP脚本
- linux用crontab执行yii脚本不成功
- Linux Crontab执行hadoop命令脚本失败
- 邮箱地址、手机号码验证正则表达式
- pycharm快捷键大全
- 修改字符串的方法
- 编程小结
- Servlet实践
- Linux执行crontab脚本出错
- 预充电过程
- 前端CSS规范
- vs常用快捷键汇总
- easyui datagrid 批量编辑保存删除
- struts校验
- TCP协议中的三次握手和四次挥手(图解)
- 微信端从网页授权获取用户基本信息
- xcrun: error: unable to find utility "instruments", not a developer tool or in PATH