[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 409
  • Last Modified:

cpanel command execute

Hi,

I have a question about my web server.
I am using cPanel and I need to execute a command before cpanel service start up.
Since cpanel key will executed by system itself, I need to know how can I execute my command before system try to execute cPanel start command.

I have tried putting my command in  /etc/inittab but it get executed AFTER cPanel which will make it useless.

Any suggestion people ?

Thank you,
0
iranmatrix
Asked:
iranmatrix
  • 4
  • 3
1 Solution
 
ai_ja_naiCommented:
if cPanel is executed in /etc/rc1.d/, you should see to which letter and number it belongs. A lower letter will make the service start earlier.
Can you list the content of that folder?
0
 
iranmatrixAuthor Commented:
Hi,
here is my /etc/rc1.d

root@server [/etc/rc1.d]# ls
./                            K30exim@             K88auditd@
../                           K35winbind@          K88pcscd@
K01smartd@                    K36mysql@            K88syslog@
K02avahi-daemon@              K50netconsole@       K88wpa_supplicant@
K02avahi-dnsconfd@            K50snmpd@            K89dund@
K02dhcdbd@                    K50snmptrapd@        K89hidd@
K02haldaemon@                 K55bandmin@          K89netplugd@
K02NetworkManager@            K56acpid@            K89pand@
K02NetworkManagerDispatcher@  K60crond@            K89rdisc@
K02oddjobd@                   K69rpcsvcgssd@       K90bluetooth@
K03yum-updatesd@              K72autofs@           K90network@
K05anacron@                   K74ipmi@             K91filelimits@
K05conman@                    K74lm_sensors@       K91ipaliases@
K05portsentry@                K75netfs@            K92ip6tables@
K05saslauthd@                 K85courier-authlib@  K92iptables@
K10assp@                      K85mdmonitor@        K95firstboot@
K10cpanel@                    K85mdmpd@            K95kudzu@
K10psacct@                    K85messagebus@       K97sysstat@
K10securetmp@                 K85rpcgssd@          K99microcode_ctl@
K15httpd@                     K87irqbalance@       K99readahead_early@
K20nfs@                       K87mcstrans@         K99readahead_later@
K24irda@                      K87multipathd@       S02lvm2-monitor@
K25sshd@                      K87named@            S06cpuspeed@
K30courier-imap@              K87restorecond@      S99single@



please note that i want to use respawn action for this command in order to avoid killing it.
0
 
ai_ja_naiCommented:
ok, put there your script and name it K9scriptname or less (K8,K7, etc) and it will be started before K10cpanel
Watchout that you should to add it with update-runlevels utility and then change the name to increase execution priority
0
Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

 
iranmatrixAuthor Commented:
but in this solution i cant use respawn to control if its killed and auto restart it.
is there any solution to use init instead of rc?
0
 
ai_ja_naiCommented:
I beg your pardon, but you are making it a priority problem: you want to start it before another program starts up in the boot process. The runlevel control is the only way to make sure it goes before.

To check if it goes down, you can put a cron script set on every 5 mins to check from ps output if it's on
0
 
iranmatrixAuthor Commented:
Hi,
there is no need to write something to check and put it in cron
finally found that i can add:

S1:345:wait:COMMAND

before any RC ( cpanel included )

then after all RC loaded add :

S2:345:wait:KILL COMMAND
S3:345:respawn:COMMAND

in /etc/inittab , thats it ! it will start before cPanel and init will monitor each time it fails ;)
0
 
ai_ja_naiCommented:
fine, accept your own solution if you think it's the best :)
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now