## Nginx is working but : nginx.service: Can’t open PID file on debian 10

I’m using nginx 1.20.1 on Debian 10, it’s working but on command `systemctl status nginx` this is shown:

systemd(1): Starting nginx – high performance web server…
systemd(1): nginx.service: Can’t open PID file /run/nginx.pid (yet?) after start: No such file or d
systemd(1): Started nginx – high performance web server.

I googled alot and checked permission of related folders of address `/var/usr/nginx.pid` and checked the address to be the same in both `/etc/nginx/nginx.conf` and `/usr/lib/systemd/system/nginx.service` , and good to say that `nginx.pid` is created when nginx is running and it is deleted when I stop nginx. I tried using `/usr/nginx.pid` in .conf and .service but the same problem exists. In my error.log, no error or warning is logged. Also should mention that it’s a fresh VM machine|debian and a fresh nginx! With no extra modification to default nginx.conf !

Question: should I have notice `Can't open PID file /run/nginx.pid (yet?) after start: No such file or d` ? If it is important how could I resolve it?

## controller – PID finetuning for central heating

I’m currently building & programming a controller for an electrical central heating.
The system has the following hardware components:

• heater
• pump
• temperature sensors

To control the temperature in the heating system, the heater and the pump have to be turned on. Both are controlled by PWM.

I decided to use a PID (Proportional Integral Derivative) controller because it’s commonly used in many solutions.

The first test I did was already successful with the following settings:

• SetPoint 55°C
• P 10
• I 2
• D 10

The target temperature of 55°C is never reached, but I’m very happy with the stable heater results. The heater is using around 80% power which results in a stable temperature output.

I performed more tests to see if I can tune the settings to reach the SetPoint, but I discovered that the heater control becomes more unstable (fluctuates between 50% and 100%) with these settings:

• SetPoint 55°C
• P 82
• I 25
• D 70

This can be explained because I’m using the output of the PID to control the heater. So the closer it gets to the setpoint, the smaller the PID output.
But to keep the temperature at 55°C, the heater probably needs to be at 90% power.
So how do I finetune the system? I’m thinking about:

• put the SetPoint to 60°C and try if the PID stabilize around 55°C
• use a bias (for example heater = 50% + PID output)

My PID controller uses the following formula:

``````heater = kp_gain * pid_error + (kd_gain * (pid_error - pid_error_old) / 55) + (ki_gain * (pid_error + pid_error_old) / 55);
``````

## adb – How to find PID of test runner

I have my app and my tests saved as following:

``````App package name: com.my.app
Test runner: com.my.app.test
``````

When I run the app by itself, I can use adb to see the pid of my app: `adb shell ps | grep com.my.app`

``````u0_a839      14710  1044 41927360 714352 0                  0 S com.my.app
``````

When I run my app with automation, I tried calling the same adb command while the tests were running: `adb shell ps | grep com.my.app.test`
But nothing shows up.

## python 3.x – Start and kill thread on given pid

I have been working on I/O Bound application where I want to learn how I can kill a thread on given PID, by PID I mean a specific URL I want to kill as I later on will do an API or listen to a stream file which will tell me which PID to kill in the future. Before I am coming to that part I would see if I am able to do a kill thread before I implement a API/Listen to a stream function.

I have created this code:

``````import sys
import time

import requests

store_pids = {}

URLS = (
"https://www.bbc.co.uk/",
"https://www.sydsvenskan.se/",
"https://www.nbcnews.com/"
)

def __init__(self, *args, **keywords):
self.killed = False

def start(self):
self.__run_backup = self.run
self.run = self.__run

def __run(self):
sys.settrace(self.globaltrace)
self.__run_backup()
self.run = self.__run_backup

def globaltrace(self, frame, event, arg):
if event == 'call':
return self.localtrace
else:
return None

def localtrace(self, frame, event, arg):
if self.killed:
if event == 'line':
raise SystemExit()
return self.localtrace

def kill(self):
self.killed = True

def each_url(given_url):
while True:
# Webcrawling site to check for new news coming
rep = requests.get(given_url)
print(f"Request status code: {rep.status_code} -> URL: {given_url}nSleep 3 sec")
time.sleep(3)

if __name__ == '__main__':

for url in URLS:
store_pids(url) = MyThread(target=each_url, args=(url,))
store_pids(url).start()

# Check if we actually have killed the process
print("---------------")
print(f"Wait 10 seconds before terminating: Current threads running:")
for key, value in store_pids.items():
if thread == value:
print(key, value)
print("---------------")

# Sleep 10 seconds
time.sleep(10)

# Kill specific URL
print("Killing https://www.sydsvenskan.se/....")
store_pids("https://www.sydsvenskan.se/").kill()
store_pids("https://www.sydsvenskan.se/").join()
del store_pids("https://www.sydsvenskan.se/")

# Check if its killed
print("---------------")
print(f"Current threads running after the kill")
for key, value in store_pids.items():
if thread == value:
print(key, value)
print("---------------")
``````

It does seem to work as I want to where it actually kills the specific thread but I wonder what can I do to even improve this code even more! 🙂

Looking forward!

## ps – How to kill openerp when it changes PID?

How do I kill `openerp` so that `odoo` can run correctly?

``````nicholas@mordor:~\$
nicholas@mordor:~\$ ps aux | grep openerp
nicholas   75353  0.0  0.0  17528   880 pts/0    S+   18:46   0:00 grep --color=auto openerp
nicholas@mordor:~\$
nicholas@mordor:~\$ ps aux | grep openerp
nicholas   75356  0.0  0.0  17528   880 pts/0    S+   18:46   0:00 grep --color=auto openerp
nicholas@mordor:~\$
nicholas@mordor:~\$ ps aux | grep openerp
nicholas   75358  0.0  0.0  17528   880 pts/0    S+   18:46   0:00 grep --color=auto openerp
nicholas@mordor:~\$
nicholas@mordor:~\$ lsof -i :880
nicholas@mordor:~\$
nicholas@mordor:~\$
nicholas@mordor:~\$ ps aux | grep openerp
nicholas   75388  0.0  0.0  17528   880 pts/0    S+   18:48   0:00 grep --color=auto openerp
nicholas@mordor:~\$
nicholas@mordor:~\$ kill 17528
bash: kill: (17528) - No such process
nicholas@mordor:~\$
nicholas@mordor:~\$ kill 75388
bash: kill: (75388) - No such process
nicholas@mordor:~\$
nicholas@mordor:~\$ ps aux | grep openerp
nicholas   75394  0.0  0.0  17528   816 pts/0    S+   18:49   0:00 grep --color=auto openerp
nicholas@mordor:~\$
``````

## append rsyslog PID in template filename

I have a template in my rsyslog and what i wish to do is add the process id of rsyslog to the end of the generated file. Note here that i need the pid of rsyslog server not the pid of the process generating the message.

My template :

``````\$template FULL_FQDN,"/logs/rsyslog/%\$YEAR%/%\$MONTH%/%\$DAY%/%HOSTNAME%_<pid_here>.log"
``````

Is there any way to achieve this in rsyslog?

## command line – How to set name for java -jar process and store pid to file

I would like to set name for process which triggers java -jar command. For example this command:

``````java -jar selenium-server-standalone-3.141.59.jar -role hub
``````

I would like to set this process name and store its pid to file. Like other services e.g. Apache has its name next to pid. But all java commands are named as java and it is useless. I found some scripts to store pid but it looks like it is super complicated. Thanks for any help.

## python – Server quit without updating PID file when trying to start MySQL server?

So I created my .bash_profile, opened it in a text editor and added:

``````export PATH=\$PATH:/usr/local/mysql/bin
``````

and then I saved it. Next, I tried running

``````sudo /usr/local/mysql/support-files/mysql.server start
``````

was told to enter my password (so I did), and then terminal said

``````Starting MySQL
``````

and then it kept printing dots until it said:

``````ERROR! The server quit without updating PID file (/usr/local/mysql/data/Nicks-MacBook-Pro.local.pid).
``````

The error logs look like:

``````2021-01-25T20:50:49.707062Z 0 (System) (MY-010116) (Server) /usr/local/mysql/bin/mysqld (mysqld 8.0.23) starting as process 15092
2021-01-25T20:50:49.710232Z 0 (Warning) (MY-010159) (Server) Setting lower_case_table_names=2 because file system for /usr/local/mysql/data/ is case insensitive
2021-01-25T20:50:49.834599Z 1 (System) (MY-013576) (InnoDB) InnoDB initialization has started.
2021-01-25T20:50:49.943719Z 1 (System) (MY-013577) (InnoDB) InnoDB initialization has ended.
2021-01-25T20:50:50.037810Z 0 (System) (MY-011323) (Server) X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /tmp/mysqlx.sock
2021-01-25T20:50:50.125494Z 0 (Warning) (MY-010068) (Server) CA certificate ca.pem is self signed.
2021-01-25T20:50:50.126128Z 0 (System) (MY-013602) (Server) Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2021-01-25T20:50:50.151069Z 0 (System) (MY-010931) (Server) /usr/local/mysql/bin/mysqld: ready for connections. Version: '8.0.23'  socket: '/tmp/mysql.sock'  port: 3306  MySQL Community Server - GPL.
~
~
~
~
~
(END)
``````

How do I fix this?

## macos – In Mac, how to do `tail -f –pid` to terminate after process exit like Linux?

`tail` command in current Linux has `--pid` option to terminate after certain process id, while tail under MAC OSX doesn’t have the same option.
e.g. `tail -f --pid=<process_pid>` can terminate tail mode if process_pid terminated.

So how can we get the same result as Linux `tail -f --pid`?

## ac.commutative algebra – Example of a PID with a residue field of finite characteristic and a residue field of characteristic 0?

I understand that for any nonempty set $$S$$ of characteristics, there exists a PID $$R$$ such that the set of characteristics of residue fields of $$R$$ is precisely $$S$$. I learned this from a paper of Heitmann (which proves much more), which I originally found here.

Question: What is a “nice” example of a PID $$R$$ such that $$R$$ has a residue field of characteristic 0 and a residue field of finite characteristic?

By “nice”, I’d ideally mean that $$R$$ is not just custom-built for the purpose of providing such an example, and might be a ring I’d meet on the street one day. Failing that, I’d settle for a streamlined description of such a ring $$R$$ (in order to understand Heitmann’s example one must wade through several layers of extra generality related to his more ambitious aims).

If we only require $$R$$ to be Noetherian, then YCor gave a simple example in the comments here: $$R = mathbb Z_p(t)$$ has residue fields $$mathbb F_p$$ and $$mathbb Q_p$$ (the latter obtained by modding out by $$(1-pt)$$). Similarly, $$mathbb Z_{(p)}$$ has residue fields $$mathbb F_p$$ and $$mathbb Q$$. It would be nice if there were an example of a PID with this property just as “nice” as $$mathbb Z_p(t)$$.