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.

Run root shell script in background

Discussion in 'General Discussion' started by JanKrohn, Jan 10, 2015.

  1. JanKrohn

    JanKrohn Active Member

    Joined:
    May 6, 2013
    Messages:
    26
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Phnom Penh
    cPanel Access Level:
    Root Administrator
    Hi,

    I need to run a shell script to remove some mailman archives (prune_arch).
    However, that script requires root access, and runs for a few hours. My internet connection is a bit unstable though, so that I can't complete the process properly.

    Is there any way to execute that script in the background, and write the output to a text file?

    Best wishes,
    Jan
     
  2. secureconfig

    secureconfig Member

    Joined:
    Jan 11, 2015
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    hello

    you need create cronjabs !
    run this command :
    crontab -e
    then crontab file should open and you need to add cronjabs codes.
    for example :
    0 * * * * /usr/bin/myscript >> /root/myscript.log
    this cronjab run every hour and save output to /root/myscript.loh

    Good Luck.\
     
  3. triantech

    triantech Well-Known Member

    Joined:
    Jul 1, 2014
    Messages:
    145
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Kochi, India, India
    cPanel Access Level:
    Root Administrator
    Hey,

    You can run your script in a screen. If it is not installed in your server, you can install it via SSH :
    Code:
    yum install screen
    Once the installation is complete, you can check the screen man page for more details on setting up the screen.
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,807
    Likes Received:
    667
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
  5. JanKrohn

    JanKrohn Active Member

    Joined:
    May 6, 2013
    Messages:
    26
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Phnom Penh
    cPanel Access Level:
    Root Administrator
    Thanks! Trying a cron job for now, since I'm familiar with those from the cPanel interface.
     
Loading...

Share This Page