SOLVED Does cpanel service manager interfere with cron jobs?

jeffschips

Well-Known Member
Jun 5, 2016
337
52
78
new york
cPanel Access Level
Root Administrator
I need to setup a cron job to stop and start mysqld. My concern is that when it goes down server manager will try to restart or issue warnings when my desire *is* for it to go down for a specific period of time everyday and not be restarted by server manager. . .
 

ffeingol

Well-Known Member
PartnerNOC
Nov 9, 2001
943
422
363
cPanel Access Level
DataCenter Provider
I believe the answer will be dependent on how log it's down. Are you just restarting MySQL or leaving it down for an extended period of time?
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
16,526
2,607
363
cPanel Access Level
Root Administrator
Hey there! It sure will - we'll detect the service as down during our checks and try to restart it. Is this related to the server load issues from the other post? You could use the API to disable service monitoring during that time as part of a larger bash script using this tool: Enable or disable a service and its monitoring
 

jeffschips

Well-Known Member
Jun 5, 2016
337
52
78
new york
cPanel Access Level
Root Administrator
yes it is related to the server load issues from the other post. yes I see that i can enable/disable in the whm gui interface for services. I don't want to globally turn off monitor/restart in the gui and I'm guessing I will need to use a script or activate a script in a cron job. Based on what you sent me to can you confirm that my option would be run this command in a cron job as such:


I don't see in that string the command to actually shut it down or turn it on. . . unless ".version=1" is the trigger but that seems more like a reference to the actual version number of the json-api. . .

Is this what you referring to?
 

jeffschips

Well-Known Member
Jun 5, 2016
337
52
78
new york
cPanel Access Level
Root Administrator
yeah I thought so, too. Thanks cPRex much appreciate the clarity.

Speaking of clarity, why does this forum always ask for my tracking preferences when logging in? This seems like a new thing but since my computer automatically deletes cookies on a regular basis, why can't it remember my preferences by my email address as most other posting services do that so we don't always have to unclick our preferences to enter the forum. I know this is message is not for this particular forum so advise where should I request this. . . thanks again.
 

jeffschips

Well-Known Member
Jun 5, 2016
337
52
78
new york
cPanel Access Level
Root Administrator
I must be missing something here - if the cron job is to enter for example, https://1.2.3.4:2087/cpsess########...service?api.version=1&service=mysql&enabled=1 (with of course the correct ip address), into a cron job for enabling the service, and if that cpsess####### changes with every request, how is it generated - I tested this and it's faulting because the cpsess##### doesn't exist. . . is it literally "cpsess##########" in the hard-coded URL in the cron job?
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
16,526
2,607
363
cPanel Access Level
Root Administrator
No, you wouldn't be able to use a cron job like that.

For a cron, it would be best to use the Bash/command line API instead of the URL version, which uses the WHMAPI1 command line option:

Code:
whmapi1 configureservice service='mysql' enabled=1