Friday 15 April 2011

Creating a startup daemon for a shell script in FreeBSD -


I am trying to create a file in rc.d / which I wrote a / bin / sh script initially Will do it. I've followed some examples found here:

  #! / Bin / sh -x # Available: copyfiles /etc/rc.subr name = copyfiles rcvar = copyfiles_enable pidfile = "/ var / run / $ {name} .pid" command = "/ var / etc / copy_dat_files.sh -f /var/etc/copydatafiles.conf "command_orge =" & amp; " Load_rc_config $ name run_rc_command "$ 1"   

It seems that I have a problem with the PDF file, should my script be one that creates a PID file, or is it automatically Is made from? I have tried both ways, and whether I make my script a PID file or not, I get an error that the PID file is not readable

if my script is about to make it , Then what is the correct way to create a PID file?

Thanks

For example, look at existing daemons (like / etc / rc .d / mountd). Then look at the sub-routine in /etc/rc.subr - there is a code to see the PID-file but nothing creates it.

In other words, you can declare the daemon-initially the script, the pid-file, but by making it depend on the daemon, speaking of daemon, you use daemon (8) utility If your demon is actually a shell script, utility will take care of creating a PID-file for you (if you have been typed in daemon C, you can use the daemon (3) function.)

BTW, Mary In health, even during the opening of the demons, PID-files, Em> Lock with them (the flock (3) or Fsiantiel (2) or Lokf (3)). In this way, if there is an instance crash (or killed) without removing the PID-file, then there will be no problem determining the next instance, the file is stale.

No comments:

Post a Comment