crontab 脚本没有执行

husion01 2015-05-31 01:25:43
我用的是ubuntu
我在/etc/crontab里面增加如下:(每2分钟执行脚本test.sh一次)
*/2 * * * * /home/123/share/456/test.sh



但好像脚本test.sh都没有被执行。

脚本内容如下:
#!/bin/sh

make


我直接运行./test.sh是可以执行的。
我也有重新启动crontab:
test@ubuntu:~$ /etc/init.d/cron start
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service cron start

Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the start(8) utility, e.g. start cron

------------------------------------------------------------------------------------------------------
test@ubuntu:~$ /etc/init.d/cron restart
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service cron restart

Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the stop(8) and then start(8) utilities,
e.g. stop cron ; start cron. The restart(8) utility is also available.
stop: Rejected send message, 1 matched rules; type="method_call", sender=":1.34" (uid=1000 pid=10073 comm="stop cron ") interface="com.ubuntu.Upstart0_6.Job" member="Stop" error name="(unset)" requested_reply="0" destination="com.ubuntu.Upstart" (uid=0 pid=1 comm="/sbin/init")

状态如下:
test@ubuntu:~$ sudo service cron status
[sudo] password for test:
cron start/running, process 7214


...全文
985 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
lixin_4055 2015-06-03
  • 打赏
  • 举报
回复
跟执行路径有关系,你再test.sh里面先用cd跳转到指定目录在执行make就行了。 crontab执行时的路径并不是test.sh所在目录的路径。 大概改成这样就可以了

SYS_DIR=$PWD
cd /home/123/share/456
make
cd $SYS_DIR
P_newer 2015-06-03
  • 打赏
  • 举报
回复
2 * * * * /home/123/share/456/test.sh
husion01 2015-06-02
  • 打赏
  • 举报
回复
高手们都放假了吗,请教了~~~
husion01 2015-06-02
  • 打赏
  • 举报
回复
Up...请教
husion01 2015-06-01
  • 打赏
  • 举报
回复
up....

2,161

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 UNIX文化
社区管理员
  • UNIX文化社区
  • 文天大人
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧