newsyslog: pid file doesn't exist: /var/run/lighttpd.pid - freebsd

We're running lighttpd-1.4.26 on FreeBSD 7.2-RELEASE. Each time we rebooted the machine, and the lighttpd was started by rc script, the pid file won't automatically write into /var/run/lighttpd.pid.
Howerver, if we start the lighttpd manually by running /usr/local/etc/rc.d/lighttpd start, the pid file will be fine.
Does any know how to solve this problem?

When you say "the lighttpd was started by rc script", are you referring to the /usr/local/etc/rc.d/lighttpd, or some other script?
Because you really should be using the same script -- indeed, the /usr/local/etc/rc.d/lighttpd will start it for you at boot, if lighthttpd_enable is set in you rc.conf -- but your wording makes me think, you use a different script at boot. It may even be, you edited /etc/rc for the purpose (a big no-no).

Related

Update bluetooth supervision_timeout parameter on Arch Linux during startup

We're dealing with an issue related to Bluez supervision_timeout value of 42 on a BLE connection. After following Excessive Bluetooth LE timeouts on Linux? and increasing the supervision_timeout to 200, we've found a significant decrease in BLE connection timeouts.
Here's the issue: We are creating our own Archiso ISO on the computers but cannot write to /sys/kernel/debug/bluetooth/hci0/supervision_timeout during chroot as the /sys/kernel directory does not exist at the time.
If the file does get updated when the computer starts (manually writing to file using nvim as root), the file goes back to the value of 42 on computer restart.
So I've got a couple possibilities, but unsure how to perform them.
During Archiso installation, make the supervision_timeout file be 200 instead of 42 (though we can't just copy a file during the chroot process as again, /sys/kernel/.../ directory isn't there at that point). Is this file something that is created from Bluez stack itself? I've been looking for documentation but can't find anything other than Bluez source files that define this number for supervision_timeout.
Write to the file every time the computer starts. However, I cannot perform this operation in the .xinitrc file as only the root user has access to /sys/kernel/debug/ directory.
Posting this to hopefully help someone else (and, admittedly, myself in case I forget as I cannot find the below forum topic from a Google search anymore).
See https://bbs.archlinux.org/viewtopic.php?id=279872
So, following V1del's advice I can successfully update the BLE
connection parameter (supervision_timeout) on startup of the computer.
I needed to change the systemd file a little bit as follows:
[Unit]
Description=Switching supervision timeout
Requires=bluetooth.service
After=bluetooth.service sys-kernel-debug.mount
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/sh -c "sleep 5; echo 200 > /sys/kernel/debug/bluetooth/hci0/supervision_timeout"
[Install]
WantedBy=multi-user.target
I found that I needed to wait for the /sys/debug/ filesystem to be
mounted, so needed to add sys-kernel-debug.mount to the After
declaration.
Note that the sleep in ExecStart is necessary as Bluetooth is not started yet.

Where should I put the "down" file to prevent Chef from starting

I am running Open Source Chef 11 Server and a dozen or so Linux and SmartOs servers running chef-client. At one point I created a file on one of my linux servers with the filename of "down" in a specific directory and that prevented the chef-client from running, even after reboot. I have since deleted this file and I cannot remember which directory I had put that file in. I can no longer find any documentation that this existed or works. Did I imagine this?
I realize the point of Chef is to have chef-client running at all times but sometimes it is useful to disable the chef-client while experimenting with the server configuration.
I believe this "down" file might be related to runit.
I think I found it.
If I create the file in /etc/sv/chef-client
# touch /etc/sv/chef-client/down
then run
# sv status chef-client
I get back
down: chef-client: 85480s; run: log: (pid 8000) 93131s
If I remove the down file I get back
down: chef-client: 85539s, normally up; run: log: (pid 8000) 93190s

How to fix Ubuntu 14.04 Apache PID not match?

Lately, every time I restart the server, Ubuntu always gives me a warning message of Apache 2 PID not match. I have to manually kill it and restart Apache 2.
I then follow the guide to check if the PID file in /var/run/apache2 is same as the one in /etc/init.d/apache2/apache2.conf, but I found that there's no file in /var/run/apache2.
I also try to follow the steps in this website
Which says "Check if pid file path set in /etc/init.d/apache2/apache2.conf equals APACHE_PID_FILE variable exported in /etc/init.d/apache2/envvars." But there's no such directory of /etc/init.d/apache2/envvars
How can I fix this? Thanks!

How to terminate an application based on file existence check in Tcl on Linux environment

I run T-Plan robot which connects to my windows machine and executes some script.
On successful execution of script,I export the generated xml file via pscp to my linux machine.
T-paln robot acts as a 3rd party freeware to pass some command via cmd on windows machine.
This takes place by running a simple batch file on t-plan robot.However,the script which sends out command to windows disconnects itself based on some explicitly declaring timeout seconds.
I want to write a tcl code which launches this application on linux machine and once the command has generated a successful outcome as xml file and is received on linux machine,it should check whether the xml file exists on the specified directory and terminates the application right at that moment.I want this because the next code section would parse this received xml report and perform other actions.
I think there should be some class in tcl which kills the process/service on any environment ,here I need to perform that in linux.
Sincerely waiting for reply .Thanks in advance
To kill a process on the same Linux machine, provided you've got permission to do so (i.e., you're running as the same user), you do either:
package require Tclx
kill $processId
Or:
exec kill $processId
(The former doesn't require an external command — it does the syscall directly — but the second doesn't need the Tclx pacakge.)
Both of these require the process ID.
To test if a file exists, use file exists like this:
if {[file exists $theFilename]} {
puts "Woohoo! $theFilename is there!"
}
To kill something on a remote machine, you need to send a command to run to that machine. Perhaps like:
exec ssh $remoteMachine kill $remotePID
Getting the $remotePID can be “interesting” and may require some considerable thought in your whole system design. If calling from Windows to Linux, replace ssh with plink. If going the other way, you're talking about doing:
exec ssh $remoteMachine taskkill /PID $remotePID
This can get very complicated, and I'm not sure if the approach you're taking right now is the right one.

Apache 2: calling 'a2ensite' from a bash script in Linux

I am currently writing an admin page for my webserver, to make it easier on myself to create new apache domains from my browser. Everything is pretty much working as I want it to, except for one thing.
To elaborate: I have a cron job on my server running a bash script as root that checks a file containing a list of domain names that I want to be created. If the file contains a domain name, it automatically creates a new virtual host for this domain, edits my hosts file, and restarts the server. This all works perfectly, however what I would like for the script to do, is that it activates the domain that it automatically creates before it restarts the server. I tried doing this using apache 2's a2ensite command, however the script returns an error saying the command is not found.
Is there a way to call this command from a bash script, or is there an alternative to this command that I can call?
Any help would be greatly appreciated.
$ which a2ensite
/usr/sbin/a2ensite
Usually, cron has a quite restrictive $PATH, not including /usr/sbin or /sbin, which are system binaries (for use by root). It's always a good idea to use fully qualified path names. So either call /usr/bin/a2ensite in your script, or define a variable:
A2ENSITE=/usr/sbin/a2ensite
...
${A2ENSITE} new-domain.com

Resources