shmu26
14 November 2022 15:50
1
The RAM usage of plasmashell steadily rises over time on my system, so I made myself a little bash script to kill it and restart it.
This is the contents of my little bash script:
#!/bin/bash
kquitapp5 plasmashell && kstart5 plasmashell
It is marked executable, and runs as expected with a double-click on the file.
Now I want it to run hourly as a cron job.
I have a file /var/spool/cron/MYUSERNAME
and its contents are
36 * * * * /home/MYUSERNAME/plasmashell_restart.sh
AFAIK it should run my little bash script on the 36th minute of every hour, but it doesn’t.
Help, please.
It looks like cronie is running:
cronie.service - Periodic Command Scheduler
Loaded: loaded (/usr/lib/systemd/system/croni>
Active: active (running) since Mon 2022-11-14>
Main PID: 41600 (crond)
Tasks: 1 (limit: 19014)
Memory: 960.0K
CPU: 10ms
CGroup: /system.slice/cronie.service
└─41600 /usr/bin/crond -n
Nov 14 17:34:37 shmuel-manjaro crond[41600]: (CRON>
Nov 14 17:34:37 shmuel-manjaro crond[41600]: (CRON>
Nov 14 17:34:37 shmuel-manjaro crond[41600]: (CRON>
Nov 14 17:34:37 shmuel-manjaro crond[41600]: (CRON>
Nov 14 17:36:01 shmuel-manjaro crond[41600]: (root>
Nov 14 17:36:01 shmuel-manjaro crond[41702]: pam_u>
lines 1-16
So I don’t know what is wrong.
System specs:
inxi -F  ✔
System:
Host: shmuel-manjaro Kernel: 6.0.6-1-MANJARO
arch: x86_64 bits: 64 Desktop: KDE Plasma
v: 5.26.2 Distro: Manjaro Linux
Machine:
Type: Desktop Mobo: ASUSTeK
model: PRIME B365M-A v: Rev X.0x
serial: <superuser required>
UEFI: American Megatrends v: 2208
date: 07/09/2021
CPU:
Info: 8-core model: Intel Core i7-9700 bits: 64
type: MCP cache: L2: 2 MiB
Speed (MHz): avg: 4242 min/max: 800/4700
cores: 1: 4705 2: 4696 3: 3000 4: 4654 5: 3000
6: 4649 7: 4551 8: 4688
Graphics:
Device-1: Intel CoffeeLake-S GT2 [UHD Graphics
630] driver: i915 v: kernel
Device-2: Microdia USB Live camera type: USB
driver: snd-usb-audio,uvcvideo
Device-3: USB C Video Adaptor type: USB
driver: N/A
Display: x11 server: X.Org v: 21.1.4
with: Xwayland v: 22.1.4 driver: X:
loaded: modesetting dri: iris gpu: i915
resolution: 1: 1920x1080~120Hz
2: 1920x1080~60Hz
API: OpenGL v: 4.6 Mesa 22.2.1 renderer: Mesa
Intel UHD Graphics 630 (CFL GT2)
Audio:
Device-1: Intel 200 Series PCH HD Audio
driver: snd_hda_intel
Device-2: Microdia USB Live camera type: USB
driver: snd-usb-audio,uvcvideo
Sound API: ALSA v: k6.0.6-1-MANJARO
running: yes
Sound Server-1: PulseAudio v: 16.1
running: yes
Sound Server-2: PipeWire v: 0.3.59
running: yes
Network:
Device-1: Realtek RTL8111/8168/8411 PCI
Express Gigabit Ethernet driver: r8169
IF: enp3s0 state: up speed: 1000 Mbps
duplex: full mac: a8:5e:45:e2:87:3c
Device-2: Realtek 802.11ac NIC type: USB
driver: rtl8821cu
IF: wlp0s20f0u2u2 state: down
mac: 4e:4c:ee:09:75:41
Device-3: Realtek RTL8153 Gigabit Ethernet
Adapter type: USB driver: r8152
IF: enp0s20f0u4u1 state: down
mac: 00:e0:4c:68:51:92
Bluetooth:
Device-1: Cambridge Silicon Radio Bluetooth
Dongle (HCI mode) type: USB driver: btusb
Report: rfkill ID: hci0 state: up
address: see --recommends
Drives:
Local Storage: total: 2.26 TiB
used: 734.56 GiB (31.8%)
ID-1: /dev/sda vendor: Kingston
model: SA400S37480G size: 447.13 GiB
ID-2: /dev/sdb vendor: Toshiba model: HDWD120
size: 1.82 TiB
Partition:
ID-1: / size: 70.72 GiB used: 27.96 GiB (39.5%)
fs: ext4 dev: /dev/sda7
ID-2: /boot/efi size: 96 MiB
used: 39.5 MiB (41.2%) fs: vfat dev: /dev/sda1
Swap:
Alert: No swap data was found.
Sensors:
System Temperatures: cpu: 32.0 C mobo: N/A
Fan Speeds (RPM): N/A
Info:
Processes: 353 Uptime: 8h 38m Memory: 15.49 GiB
used: 7.01 GiB (45.3%) Shell: Zsh inxi: 3.3.23
This seems very much like a XY problem, you should solve the issue rather than treating the symptom.
However, you might use a systemd-timer instead.
Also, the log is cut off:
journalctl -b-1 -u cronie
1 Like
shmu26
14 November 2022 15:57
3
Thanks.
1 What is a XY problem?
2 I shared the script, it is the first code snippet in my OP.
shmu26
14 November 2022 15:58
4
journalctl -b-1 -u cronie  ✔
Nov 13 11:30:01 shmuel-manjaro systemd[1]: Started>
Nov 13 11:30:01 shmuel-manjaro crond[465]: (CRON) >
Nov 13 11:30:01 shmuel-manjaro crond[465]: (CRON) >
Nov 13 11:30:01 shmuel-manjaro crond[465]: (CRON) >
Nov 13 11:30:01 shmuel-manjaro crond[465]: (CRON) >
Nov 13 12:00:01 shmuel-manjaro CROND[10790]: (root>
Nov 13 12:00:01 shmuel-manjaro CROND[10789]: (root>
Nov 13 12:00:01 shmuel-manjaro CROND[10789]: (root>
Nov 13 12:00:01 shmuel-manjaro CROND[10789]: (root>
Nov 13 12:00:01 shmuel-manjaro CROND[10789]: (root>
Nov 13 12:00:01 shmuel-manjaro CROND[10789]: (root>
Nov 13 12:00:02 shmuel-manjaro CROND[10789]: (root>
Nov 13 12:00:02 shmuel-manjaro CROND[10789]: (root>
Nov 13 12:00:02 shmuel-manjaro CROND[10789]: (root>
Nov 13 12:00:02 shmuel-manjaro CROND[10789]: (root>
Nov 13 12:00:02 shmuel-manjaro CROND[10789]: (root>
lines 1-16
Please share the full output. It seems it runs as root and not your user.
How did you create the cron entry?
Usually, you would run crontab -e
shmu26
14 November 2022 16:06
6
Okay, at least I learned what a XY problem is…
shmu26
14 November 2022 16:09
7
The full output is below, run as root.
I had trouble with crontab -e
because I didn’t know how to use the editor, so I created the cron entry with
export VISUAL=nano; crontab -e
sudo journalctl -b-1 -u cronie  ✔
[sudo] password for shmuel:
Nov 13 11:30:01 shmuel-manjaro systemd[1]: Started>
Nov 13 11:30:01 shmuel-manjaro crond[465]: (CRON) >
Nov 13 11:30:01 shmuel-manjaro crond[465]: (CRON) >
Nov 13 11:30:01 shmuel-manjaro crond[465]: (CRON) >
Nov 13 11:30:01 shmuel-manjaro crond[465]: (CRON) >
Nov 13 12:00:01 shmuel-manjaro CROND[10790]: (root>
Nov 13 12:00:01 shmuel-manjaro CROND[10789]: (root>
Nov 13 12:00:01 shmuel-manjaro CROND[10789]: (root>
Nov 13 12:00:01 shmuel-manjaro CROND[10789]: (root>
Nov 13 12:00:01 shmuel-manjaro CROND[10789]: (root>
Nov 13 12:00:01 shmuel-manjaro CROND[10789]: (root>
Nov 13 12:00:02 shmuel-manjaro CROND[10789]: (root>
Nov 13 12:00:02 shmuel-manjaro CROND[10789]: (root>
Nov 13 12:00:02 shmuel-manjaro CROND[10789]: (root>
Nov 13 12:00:02 shmuel-manjaro CROND[10789]: (root>
Nov 13 12:00:02 shmuel-manjaro CROND[10789]: (root>
lines 1-16
SYSTEMD_LESS=FRXMK journalctl -b -u cronie
shmu26
14 November 2022 16:11
9
sudo SYSTEMD_LESS=FRXMK journalctl -b -u cronie
[sudo] password for shmuel:
Nov 14 09:11:19 shmuel-manjaro systemd[1]: Started Periodic Command Scheduler.
Nov 14 09:11:19 shmuel-manjaro crond[479]: (CRON) STARTUP (1.6.1)
Nov 14 09:11:19 shmuel-manjaro crond[479]: (CRON) INFO (Syslog will be used instead of sendmail.)
Nov 14 09:11:19 shmuel-manjaro crond[479]: (CRON) INFO (RANDOM_DELAY will be scaled with factor 87% if used.)
Nov 14 09:11:19 shmuel-manjaro crond[479]: (CRON) INFO (running with inotify support)
Nov 14 10:00:01 shmuel-manjaro CROND[9270]: (root) CMD (timeshift --check --scripted)
Nov 14 10:00:01 shmuel-manjaro CROND[9269]: (root) CMDOUT ((process:9270): GLib-GIO-CRITICAL **: 10:00:01.739: g_file_get_path: assertion 'G_IS_FILE (fil
lines 1-7
When did you create the script? There’s nothing in the log about it and it seems shorter than the ones before.
shmu26
14 November 2022 16:13
11
I created it a couple hours ago
shmu26
14 November 2022 16:18
12
But as for the root problem, it seems to be a memory leak bug affecting Plasma when running on Arch with my particular GPU. I haven’t found a solution for it yet.
Plasma runs as systemd service since… 5.25 or something. Write a systemd timer.
Hail Systemd.timer(5) , death to cron
and the like
No seriously adapt to the new era…
To check logs you can use: (attribution )
journalctl -b 0 _COMM=plasmashell
shmu26
15 November 2022 12:13
16
If anyone can, please link me to a tutorial or wiki how to make a system.d timer job that runs a bash script as a standard user, not as root.
Alternatively, that will run the command
kquitapp5 plasmashell && kstart5 plasmashell
as standard user, not as root.
See systemd/User - ArchWiki and systemd/Timers - ArchWiki a timer is just a type of systemd-unit specially for timed executions.
See the link i gave in previous reply to the man page of timers.
To make a bash script executable you need to modify it’s file permissions plus add a shebang
, im sure there are plenty of pages on the internet dealing with that topic. (its super easy)
#!/bin/env bash
PS: You can split that command into 2 commands that get executed in sequence by the service file you will need to create, which will be triggered by the timer.
1 Like
shmu26
15 November 2022 14:03
18
Aha, so in systemd/User - ArchWiki I see there is an issue with path.
If you customize your PATH
and plan on launching applications that make use of it from systemd units, you should make sure the modified PATH
is set on the systemd environment. Assuming you set your PATH
in .bash_profile
, the best way to make systemd aware of your modified PATH
is by adding the following to .bash_profile
after the PATH
variable is set:
~/.bash_profile
systemctl --user import-environment PATH
Maybe that was the problem.
This has nothing to do with plasmashell or timers.
Why do you think you need to modify the path?
Create the service and timer file in ~/.config/systemd/user/
, reload the files with systemctl --user daemon-reload
and enable the timer: systemctl --user enable --now xxx.timer
.
1 Like