CoolMike

Well-Known Member
Sep 6, 2001
313
0
316
Hi

Is there a possibility to run a script right after the nightly upcp is finished?

Right now I have a cron job, but sometimes the upcp takes longer sometimes not.

Thanks
Michael
 

haze

Well-Known Member
Dec 21, 2001
1,540
3
318
If you create a file in /scripts named postupcp ( no caps ) then cpanel will run whatever is in this file when upcp finishes.
 

PWSowner

Well-Known Member
Nov 10, 2001
2,901
4
343
ON, Canada
In the upcp script is:

Code:
if (-e "/scripts/postupcp") {
   system("/scripts/postupcp");
}
If a script called postupcp exists in the /scripts directory, it will automatically be run after upcp. All you need to do is name your script postupcp and put it in the /scripts directory and it will do what you want.
 

CoolMike

Well-Known Member
Sep 6, 2001
313
0
316
Wow, great, that was exactly what I need. But I'm just wondering, how did you find out about this? Is there a documentation about this, or did you just open the upcp script and found this?

Thanks a lot!

Mike
 

CoolMike

Well-Known Member
Sep 6, 2001
313
0
316
Hi

I renamed now my script to postupcp and moved it to the script folder. When I run it, it works. But when I runt the upcp script, it will not be executed.

What could be the reason?

Thanks
Michael
 

CoolMike

Well-Known Member
Sep 6, 2001
313
0
316
Or is there an other solution? I want to run this script as soon the nightly cpbackup is finished.

Thanks
Michael
 

chirpy

Well-Known Member
Verifed Vendor
Jun 15, 2002
13,437
33
473
Go on, have a guess
Also,

1. You need to make it executable:

chmod +x /scripts/postupcp

2. You need to have a shell of some sort as the first line of /scripts/postupcp , for example:

#!/bin/sh

or for a perl script:

#!/usr/bin/perl
 

CoolMike

Well-Known Member
Sep 6, 2001
313
0
316
I did all this already and if I run the postupcp script manually, then it works. It even works, when I run the ./upcp Script manually, but it doesn't work, when in the nightly cronjob:

35 1 * * * /scripts/upcp

I just saw, that the postupcp is not really at the end of upcp. Could it be, that upcp stopps somewhere in the middle? Will the postupcp run before or after the backup? Because I need to run it definitly after the backup.

Thanks
Michael
 

PWSowner

Well-Known Member
Nov 10, 2001
2,901
4
343
ON, Canada
Sounds like in the auto mode it's not getting that far, but it should.

If you want to modify the backup script, you can have it call your script.

Open the /scripts/cpbackup file and put:

Code:
if (-e "/scripts/postupcp") {
   system("/scripts/postupcp");
}
just before:
Code:
sub isolderthen {
if you have backup enabled.

If backup is not enabled, you will have to put it just before:
Code:
if ($CONF{'BACKUPENABLE'} ne "yes") {
but you will need to change that if you enable backup later.


You can change the /scripts/postupcp that you add if you want to put your script elsewhere, or give it a different name.
 

chirpy

Well-Known Member
Verifed Vendor
Jun 15, 2002
13,437
33
473
Go on, have a guess
An alternative, which I've used in the past, is to modify the root crontab so that it runs another command after upcp:

/scripts/upcp ; /scripts/postupcp
 

PWSowner

Well-Known Member
Nov 10, 2001
2,901
4
343
ON, Canada
CoolMike, (nice name btw) ;)

If you do modify the crontab, you probably will want to change the script or path because if you call it postupcp it might end up getting run twice, by the cpanel call, (supposed to anyway), then by the cronjob call.
 

CoolMike

Well-Known Member
Sep 6, 2001
313
0
316
Great, this works now perfectly. Thanks a lot to all of you.

squirrel, the name is already very old. I used it when I was in a chat the first time. :) Maybe 15 years ago, and did never change it againg.