The FAQ already shows one way to run consolewd in the background. I wanted to share another that IMO is a bit easier since you don’t have to find the Process ID in order to control consolewd. This uses serviced, which is included in current Raspberry Pi OS distributions:
Step One: Create a Unit File
Please note this uses the default working directory of /home/pi/consolewdfiles – adjust if you run consolewd from a different directory.
sudo nano /lib/systemd/system/consolewd.service
Paste this code into the nano window and close (ctrl-X Y)
[Unit]
Description=Weather-Display
After=multi-user.target
[Service]
Type=idle
WorkingDirectory=/home/pi/consolewdfiles
ExecStart=/home/pi/consolewdfiles/consolewd
[Install]
WantedBy=multi-user.target
Change Permissions:
sudo chmod 644 /lib/systemd/system/consolewd.service
Step Two: Configure systemd
sudo systemctl daemon-reload sudo systemctl enable consolewd sudo systemctl start consolewd
consolewd is now running in the background as a service and it will start when the system reboots.
You can verify consolewd is working with:
systemctl status consolewd
Output looks something like this and includes the most recent output:
pi@raspberrypi:~ $ systemctl status consolewd
● consolewd.service - Weather-Display
Loaded: loaded (/lib/systemd/system/consolewd.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2020-12-03 13:40:04 CST; 42s ago
Main PID: 6741 (consolewd)
Tasks: 1 (limit: 4915)
CGroup: /system.slice/consolewd.service
└─6741 /home/pi/consolewdfiles/consolewd
Dec 03 13:40:41 raspberrypi consolewd[6741]: 200 OK
Dec 03 13:40:42 raspberrypi consolewd[6741]: [57B blob data]
Dec 03 13:40:42 raspberrypi consolewd[6741]: [182B blob data]
Dec 03 13:40:42 raspberrypi consolewd[6741]: Current data 13WU data to send http://rtupdate.wunderground.com/weatherstation/updateweatherstation.php?realtime=1&rtfreq=10&action=updateraw&ID=KT
Dec 03 13:40:42 raspberrypi consolewd[6741]: Wunderground data send Ok 13:40:42
Dec 03 13:40:43 raspberrypi consolewd[6741]: 200 OK
Dec 03 13:40:44 raspberrypi consolewd[6741]: [167B blob data]
Dec 03 13:40:44 raspberrypi consolewd[6741]: Current data 13:40:44: Temperature= 46.0F, Windspeed =7.3 Gustspeed =7.0 Direction =264 WU data to send http://rtupdate.wunderground.com/weathersta
Dec 03 13:40:44 raspberrypi consolewd[6741]: rainin=0.00&baromin=30.227&dewptf=39.5&weather=&clouds=CLR&dailyrainin=0.00&softwaretype=WeatherDisplay%3AWD_console_21.1
Dec 03 13:40:44 raspberrypi consolewd[6741]: Wunderground data send Ok 13:40:44
pi@raspberrypi:~ $
You can control consolewd with these commands:
sudo systemctl start consolewd
sudo systemctl stop consolewd
sudo systemctl restart consolewd
I find that just doing a sudo systemctl restart consolewd is enough to get changes I have made to config.txt to be reloaded, but if I’m going to run consolewd in the foreground to test / make major changes to config.txt, I stop the service and start it again when I’m done.
More detail on how systemd works here: https://www.dexterindustries.com/howto/run-a-program-on-your-raspberry-pi-at-startup/