crontab中引入环境变量(比如需要执行tomcat的关闭启动)时间:2023-03-09 18:01:55 起因 crontab中的定时任务,执行到关闭tomcat时,报环境变量找不到 解决方案 1.使用 . /etc/profile 引入环境变量 ###推荐, 实测ubuntu12 成功 2.使用 source /etc/profile 引入环境变量 ###不推荐,实测ubuntu12 失败 注意 . /etc/profile中 . 和 /etc/profile之间是有空格的,我就是被这个坑了。一定要加空格,切记~