Run root shell script in background

JanKrohn

Well-Known Member
May 6, 2013
49
4
8
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
 

secureconfig

Member
Jan 11, 2015
5
0
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.\
 

triantech

Well-Known Member
Jul 1, 2014
143
1
18
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.