Reputation: 1430
I created the following script to stop apache and mysql and then restart them. When started manually it works fine, however when executed from a daily cron job I can see the logs, but the database is NOT restarted. Any idea why?
#!/bin/sh
PATH=/bin:/usr/bin
service apache2 stop
echo $(date ) "Apache stopped"
sleep 15
service mysql stop
echo $(date ) "Mysql stopped"
sleep 60
service mysql start
echo $(date ) "Mysql started"
sleep 5
service apache2 start
echo $(date ) "Apache started"
Upvotes: 1
Views: 693
Reputation: 577
Try changing service mysql
with /etc/init.d/mysql
.
Similarly, try using /etc/init.d/apache2
instead of service apache2
.
Also, try with #!/bin/bash
shebang.
Upvotes: 3