The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Write a Cronjob on CloudLinux server to run a sh file to restart a service periodicly

Discussion in 'CloudLinux' started by armin654, Mar 17, 2014.

  1. armin654

    armin654 Well-Known Member

    Joined:
    Feb 12, 2014
    Messages:
    45
    Likes Received:
    0
    Trophy Points:
    6
    cPanel Access Level:
    Root Administrator
    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
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,776
    Likes Received:
    663
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
  3. dalem

    dalem Well-Known Member
    PartnerNOC

    Joined:
    Oct 24, 2003
    Messages:
    2,577
    Likes Received:
    40
    Trophy Points:
    48
    Location:
    SLC
    cPanel Access Level:
    DataCenter Provider
    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
     
  4. armin654

    armin654 Well-Known Member

    Joined:
    Feb 12, 2014
    Messages:
    45
    Likes Received:
    0
    Trophy Points:
    6
    cPanel Access Level:
    Root Administrator
    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
    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 much
     
  5. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,776
    Likes Received:
    663
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
Loading...

Share This Page