/etc/init.d/mysql start
通过shell命令执行时工作
当放入bash脚本,然后执行bash脚本时工作
但是,当我尝试从cronjob执行此脚本时
我收到这个错误
/etc/init.d/mysql:73:start:not found
任何解释以及我如何解决这个问题
我在Ubuntu 10.0上
oilChange.sh
#!/bin/bash
pgrep mysql -c
service apache2 stop
sleep 1s
/etc/init.d/mysql stop
sleep 1s
/sbin/swapoff -a
sleep 1s
/sbin/swapon -a
sleep 1s
/etc/init.d/mysql start
sleep 1s
if [-le "0" ]; then /etc/init.d/mysql start; fi
pgrep apache -c
sleep 1s
service apache2 start
sleep 1s
if [-le "0" ]; then service apache2 start; fi
sleep 1s
cd /root/crt
php twatch3.php
这是记录在/ var / mail / root
中的内容
Subject: Cron <root@cloud> bash /root/crt/oilChange.sh
Content-Type: text/plain; charset=ANSI_X3.4-1968
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/root>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=root>
* Stopping web server apache2
... waiting ...done.
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service mysql stop
Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the stop(8) utility, e.g. stop mysql
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service mysql 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 mysql
/etc/init.d/mysql: 73: start: not found
* Starting web server apache2
...done.
root@cloud:~#
I have tried
service mysql stop
stop mysql
Both work from cmd prompt, and
script execution from cmd prompt but
fail when the script is executed by the cron
答案 0 :(得分:1)
crontab man页面指出PATH变量设置为保证找到所有标准实用程序的值。更新并导出路径变量以包括所有实用程序。
答案 1 :(得分:0)
可能是因为它不是脚本,而是带有添加参数的脚本。您可能需要"
或类似的东西。