cpanel command execute


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,
Who is Participating?
iranmatrixConnect With a Mentor Author Commented:
there is no need to write something to check and put it in cron
finally found that i can add:


before any RC ( cpanel included )

then after all RC loaded add :

S2:345:wait:KILL COMMAND

in /etc/inittab , thats it ! it will start before cPanel and init will monitor each time it fails ;)
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?
iranmatrixAuthor Commented:
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.
Improve Your Query Performance Tuning

In this FREE six-day email course, you'll learn from Janis Griffin, Database Performance Evangelist. She'll teach 12 steps that you can use to optimize your queries as much as possible and see measurable results in your work. Get started today!

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
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?
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
fine, accept your own solution if you think it's the best :)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.