Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8950457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:27:35+00:00 2026-06-15T13:27:35+00:00

I need to control (start\stop\restart) a perl daemon from a web application (php). Daemon

  • 0

I need to control (start\stop\restart) a perl daemon from a web application (php).
Daemon starts (and run) correctly when I use my init script (/etc/init.d/foodaemon start (works fine) ) from command line, but doesn’t works (daemon is down but pid file is created, as if the daemon died after its creation) when I try to launch from application.
In my /etc/sudoers, I added

apache  ALL = NOPASSWD: /etc/init.d/foodaemon

In my php script,

$cmd = "/usr/bin/sudo /etc/init.d/foodaemon start";                             
exec($cmd,$out,$ret);

I have all permissions. The perl script is

#!/usr/bin/perl
use strict;
use warnings;
use Proc::Daemon;
Proc::Daemon::Init;

my $continue = 1;
$SIG{TERM} = sub { $continue = 0 };

close STDIN;
open STDERR,">>/tmp/mylog";
print "My pid: $$\n";
close STDOUT;

while ($continue) {

        # ... what I need        
}   
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T13:27:36+00:00Added an answer on June 15, 2026 at 1:27 pm

    SOLVED… There was an error in my init.d script, or rather

    case "$1" in
        start)
            if [ -z "$(pgrep $DAEMON)" ]
            then
    
                # DAEMON is not running                         
                printf "%-50s" "Starting $NAME..."
    
                cd $DAEMON_PATH
                PID=`$DAEMON > /dev/null 2>&1 & echo $!`
    
                #echo "Saving PID" $PID " to " $PIDFILE
                if [ -z $PID ]; then
                    printf "%s\n" "Fail"
    

    I did not have permission to do

    cd $DAEMON_PATH
    

    so, I update as follow

     #cd $DAEMON_PATH
     PID=`$DAEMON_PATH/$DAEMON > /dev/null 2>&1 & echo $!`
    

    and It works…Sorry…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to programmatically start or stop a flow or endpoint from another flow.
I have an application that will only stop/start services if it is run as
I need to control inbound and outbound traffic to/from a linux box from within
I need a control having these features: It should be possible use it in
I've to create an activeX control that need to run without any prerequisit (like
I need a timer class which should provide functionality to start/stop/enable/disable and should be
I am writing PowerShell scripts to control SQL Server agent start/stop to ensure all
I have XAMPP installed on Windows 7. I need to stop and start Apache
I have a service that I need to be able to start and stop
I need to play a movie without any overlay from the player. No play/stop

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.