Reputation: 1910
I want to run apollo-broker-service service using cron job on CentOS 7. For this I am created a file /home/guest/start_apollo mentioned below
#!/bin/bash
if pidof -x "apollo" >/dev/null; then
echo "Apollo MQTT is Running."
else
echo "Apollo MQTT is Stopped."
service apollo-broker-service start
fi
I am login with ssh root and run following command
cd /home/guest/
chown root start_apollo
chgrp -R root start_apollo
chmod +x start_apollo
I want to run /home/nagios/start_apollo every 1 minute For this I added the following line into /etc/crontab
01 * * * * root /home/nagios/start_apollo > /var/log/start_apollo_service.log
I created a /var/log/start_apollo_service.log with following permission
-rwxr-xr-x 1 root root 0 Aug 11 20:08 start_apollo_service.log
then restart crond service using below command
systemctl restart crond.service
After all this my cron job not working and there is no log created on /var/log/start_apollo_service.log
Upvotes: 3
Views: 2975
Reputation: 1910
I resolved my issue by using the following
*/1 * * * * root /home/nagios/start_apollo > /var/log/start_apollo_service.log
Upvotes: 1
Reputation: 350
I believe that your cronjob is not set to run every 1 minute but once every hour at the minute 1.
Try this first, and then change it if you really meant once every hour at minute 01:
* * * * * root /home/nagios/start_apollo > /var/log/start_apollo_service.log
Upvotes: 2