cPanel Hooks or special configs for specific actions
Hello,
I need to perform specific actions before and after a cPanel server does scheduled tasks,
like the daily backups and the update of the system...
I am using the new backup system / daemon and the stable tier for updates and
have scheduled these services through WHM crons scheduler to execute:
update @ 1:00 AM
backup @ 2:00 AM
I know I could just put a cron to perform the tasks I need, just few mins before
these times, but there is no easy way to detect when / if they finished,
so I was wondering, if there is another way, to be able to configure an .sh
script or command, to be executed, before and after these services run...
Any ideas and insight will be highly appreciated !
Thanks,
Ryan
-
Hi Ryan, Thanks for the question! cPanel has standardized hook points that execute before and after system backups run. There are also hook points that run before, during, and after each individual account backup, if you need finer-grained control. It sounds like these are the hook points you'll need: 0 -
Hi Ryan, Thanks for the question! cPanel has standardized hook points that execute before and after system backups run. There are also hook points that run before, during, and after each individual account backup, if you need finer-grained control. It sounds like these are the hook points you'll need:
Thank you David for your reply and help with this. It seems that backup system does actually already have an advanced method to satisfy all my needs, I checked the SDK and it's pretty much straight-forward for my needs... Do you have any suggestion also regarding the update system ("upcp" scheduled daemon) ??? Thanks again, waiting for your news regarding upcp.0 -
Hello, yes, this seems to be what I am looking for, but still, I am unable to find how to achieve my task... Is there any real-life example, how I can actually implement these things ??? For example, let's say, I want to execute the following scripts: /usr/local/src/custom/updates/before.sh /usr/local/src/custom/updates/after.sh /usr/local/src/custom/backups/before.sh /usr/local/src/custom/backups/after.sh Can you please give me a real-life example, how these 4 scripts can be set to execute, each at the proper time ??? (Please note that the paths and filenames are self-explaining of what goes where...) Thanks for any help in advance !!! 0 -
Hello, I have the following scripts: 1: /usr/local/src/custom/updates/before.sh 2: /usr/local/src/custom/updates/after.sh 3: /usr/local/src/custom/backups/before.sh 4: /usr/local/src/custom/backups/after.sh Each script, is a bash script, tested to work in standalone / shell execution mode (already chmoded to +x). Can anyone help me and explain me how I can add these scripts to execute at the proper time via cPanel Hooks system ??? 1: should run, BEFORE cPanel updater runs (before upcp) 2: should run, AFTER cPanel updater completes (after upcp) 3: should run, BEFORE cPanel new backups runs (before backups) 4: should run, AFTER cPanel new backups completes (after backups) Notice: I have seen that there is also a post-upcp action running regarding CloudLinux, my script should execute AFTER this is also completed. Actually, my scripts should explicitly execute before and after the cPanel daemons run. Thanks on advance for your help !!! 0 -
I've merged your post into this thread. Could you let us know if the last response in the thread referenced earlier is helpful? Thank you. 0 -
Hi Ryan, To get your hook scripts to run, you'll need to register them into the hooks database with the utility /usr/local/cpanel/bin/manage_hooks. The --help output there should be enough information to get you started. If you have any more questions, please let us know. Thanks! David Nielson Integration Developer, cPanel 0 -
Is it possible to do this, without adding any extra code in the scripts and without the need to add them on specific paths, as indicated on the example ???
Yes, for example you can utilize a simple .sh file that runs specific commands.Notice: I have seen that there is also a post-upcp action running regarding CloudLinux, my script should execute AFTER this is also completed.
Yes, this is possible with the "--weight" option that's documented at: Guide to Standardized Hooks - The manage_hooks Utility - Software Development Kit - cPanel Documentation Thank you.0
Please sign in to leave a comment.
Comments
11 comments