cpanel command execute

Posted on 2009-04-15
Last Modified: 2013-11-30

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,
Question by:iranmatrix
    LVL 16

    Expert Comment

    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?

    Author Comment

    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.
    LVL 16

    Expert Comment

    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

    Author Comment

    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?
    LVL 16

    Expert Comment

    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

    Accepted Solution

    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 ;)
    LVL 16

    Expert Comment

    fine, accept your own solution if you think it's the best :)

    Featured Post

    Netscaler Common Configuration HowTo guides

    If you use NetScaler you will want to see these guides. The NetScaler HowTo Guides enable administrators to get NetScaler up and running by providing instructions for common configuration scenarios and some not so common ones.

    Join & Write a Comment

    If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
    Even if you have implemented a Mobile Device Management solution company wide, it is a good idea to make sure you are taking into account all of the major risks to your electronic protected health information (ePHI).
    Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
    After creating this article (, I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now