Write a Cronjob on CloudLinux server to run a sh file to restart a service periodicly
Hello there
I want to write a crobjob to restart a specific service periodically
I wrote my command in a .sh file. When i run the .sh file manually it works fine and the service is being restarted but if i add it in cronjob and specifying a time to run that .sh file, the command is not being run .
Is there anyway to read the logs of cronjobs ? do you have any experience on this issue?
Kind regards
-
Hello :) Cron jobs are logged to: /var/log/cron Out of curiosity, which service is it and why are you having to restart it? Thank you. 0 -
try putting in /bin/sh /pathtoshfile/ if that does not call it then add PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin to the top of your crontab 0 -
Dear cPanelMichael! Thank you for your care about my issue. It is just a try on my LAB machine and not something seriously. Thank you for the log location [quote="dalem, post: 1598201">try putting in /bin/sh /pathtoshfile/ if that does not call it then add PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin to the top of your crontab
Thank you dalem! The problem was that when we call the service, we should give the complete path to it and not just writing the service name. Your help guided me to the answer. Thank you so much0 -
I am happy to see the issue is now resolved. Thank you for updating us with the outcome. 0
Please sign in to leave a comment.
Comments
4 comments