Unable to create cronjobs using cronie

Hello there,
I’m new to Arch Linux and Garuda OS.

I’m trying to create my first cronjob on my first Garuda installation. To achieve this purpose, I installed cronie 1.7.2, right after I started and enabled with:

systemctl start cronie

systemctl enable cronie

Now, I ran:

crontab -e

from fish shell, a text file is opened with Kate (eg. crontab.Y7p5wl).
I read on web that this temp text file is like a buffer, so I need to write my cron entry here and save, and is what I have done, but after saved and closed the file, I can’t see my cron entry on /etc/crontab.

If helps, I’m running cron with normal user, but root user doesn’t work either.

I tried editing /etc/crontab with nano but cronjob still doesn’t work.

Someone could point me to the right direction please? On web I haven’t find much

systemctl status cronie

?

2 Likes

As new user here I can’t upload images, but here the output:

● cronie.service - Command Scheduler
Loaded: loaded (/usr/lib/systemd/system/cronie.service; enabled; preset: disabled)
Active: active (running) since Sun 2024-09-29 18:10:34 CEST; 9min ago
Invocation: abb45b0f98834a2c81a003ea157bcfd8
Main PID: 9791 (crond)
Tasks: 1 (limit: 9062)
Memory: 904K (peak: 1.7M)
CPU: 12ms
CGroup: /system.slice/cronie.service
└─9791 /usr/sbin/crond -n

set 29 18:10:34 elia-thinkpad systemd[1]: Started Command Scheduler.
set 29 18:10:34 elia-thinkpad crond[9791]: (CRON) STARTUP (1.7.2)
set 29 18:10:34 elia-thinkpad crond[9791]: (CRON) INFO (Syslog will be used instead of sendmail.)
set 29 18:10:34 elia-thinkpad crond[9791]: (CRON) INFO (RANDOM_DELAY will be scaled with factor 76% if used.)
set 29 18:10:34 elia-thinkpad crond[9791]: (CRON) INFO (running with inotify support)
set 29 18:10:34 elia-thinkpad crond[9791]: (CRON) INFO (@reboot jobs will be run at computer's startup.)

cronie is runnig as root user (saw this with ps aux command)

It’s a lot of time that I don’t use cron, but for anyone willing to help maybe it’s time to provide more details.
What you’re adding to cron, if you want to launch a script what it is like. It could be also a matter of environment variables.
And your garuda-inxi is missing in the initial post.

2 Likes

Sorry for the missing garuda-inxi output:

System:
Kernel: 6.10.10-zen1-1-zen arch: x86_64 bits: 64 compiler: gcc v: 14.2.1
clocksource: tsc avail: acpi_pm
parameters: BOOT_IMAGE=/@/boot/vmlinuz-linux-zen
root=UUID=cd382bd2-defe-4b7b-b2b4-f47cbe7d9e7d rw rootflags=subvol=@
quiet loglevel=3 ibt=off
Desktop: KDE Plasma v: 6.1.5 tk: Qt v: N/A wm: kwin_wayland dm: SDDM
Distro: Garuda base: Arch Linux
Machine:
Type: Laptop System: LENOVO product: 20HES2BD0J v: ThinkPad T470
serial: <filter> Chassis: type: 10 serial: <filter>
Mobo: LENOVO model: 20HES2BD0J v: SDK0J40697 WIN serial: <filter>
part-nu: LENOVO_MT_20HE_BU_Think_FM_ThinkPad T470
uuid: 766904cc-2148-11b2-a85c-f88b6f6149cf UEFI-[Legacy]: LENOVO
v: N1QETA1W (1.76 ) date: 11/06/2023
Battery:
ID-1: BAT0 charge: 20.0 Wh (100.0%) condition: 20.0/24.0 Wh (83.5%)
volts: 12.7 min: 11.5 model: SMP 01AV421 type: Li-poly serial: <filter>
status: full cycles: 593
CPU:
Info: model: Intel Core i5-7300U socket: BGA1356 (U3E1) note: check bits: 64
type: MT MCP arch: Amber/Kaby Lake note: check gen: core 7 level: v3
note: check built: 2017 process: Intel 14nm family: 6 model-id: 0x8E (142)
stepping: 9 microcode: 0xF6
Topology: cpus: 1x dies: 1 clusters: 2 cores: 2 threads: 4 tpc: 2
smt: enabled cache: L1: 128 KiB desc: d-2x32 KiB; i-2x32 KiB L2: 512 KiB
desc: 2x256 KiB L3: 3 MiB desc: 1x3 MiB
Speed (MHz): avg: 700 min/max: 400/3500 base/boost: 2600/2700 scaling:
driver: intel_pstate governor: powersave volts: 1.0 V ext-clock: 100 MHz
cores: 1: 700 2: 700 3: 700 4: 700 bogomips: 21599
Flags: avx avx2 ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx
Vulnerabilities: <filter>
Graphics:
Device-1: Intel HD Graphics 620 vendor: Lenovo driver: i915 v: kernel
arch: Gen-9.5 process: Intel 14nm built: 2016-20 ports: active: eDP-1
empty: DP-1, DP-2, HDMI-A-1, HDMI-A-2 bus-ID: 00:02.0 chip-ID: 8086:5916
class-ID: 0300
Device-2: Chicony Integrated IR Camera driver: uvcvideo type: USB rev: 2.0
speed: 480 Mb/s lanes: 1 mode: 2.0 bus-ID: 1-5:2 chip-ID: 04f2:b5ac
class-ID: 0e02
Device-3: Chicony Integrated Camera driver: uvcvideo type: USB rev: 2.0
speed: 480 Mb/s lanes: 1 mode: 2.0 bus-ID: 1-8:4 chip-ID: 04f2:b5ab
class-ID: 0e02
Display: unspecified server: X.Org v: 24.1.2 with: Xwayland v: 24.1.2
compositor: kwin_wayland driver: X: loaded: modesetting
alternate: fbdev,intel,vesa dri: iris gpu: i915 display-ID: :1 screens: 1
Screen-1: 0 s-res: 1920x1080 s-dpi: 96 s-size: 508x286mm (20.00x11.26")
s-diag: 583mm (22.95")
Monitor-1: eDP-1 model: AU Optronics 0x103d built: 2016 res: 1920x1080
hz: 60 dpi: 158 gamma: 1.2 size: 309x173mm (12.17x6.81") diag: 354mm (13.9")
ratio: 16:9 modes: 1920x1080
API: EGL v: 1.5 hw: drv: intel iris platforms: device: 0 drv: iris
device: 1 drv: swrast gbm: drv: iris surfaceless: drv: iris x11: drv: iris
inactive: wayland
API: OpenGL v: 4.6 compat-v: 4.5 vendor: intel mesa v: 24.2.3-arch1.1
glx-v: 1.4 direct-render: yes renderer: Mesa Intel HD Graphics 620 (KBL GT2)
device-ID: 8086:5916 memory: 3.62 GiB unified: yes
API: Vulkan v: 1.3.295 layers: 3 device: 0 type: integrated-gpu name: Intel
HD Graphics 620 (KBL GT2) driver: mesa intel v: 24.2.3-arch1.1
device-ID: 8086:5916 surfaces: xcb,xlib device: 1 type: cpu name: llvmpipe
(LLVM 18.1.8 256 bits) driver: mesa llvmpipe v: 24.2.3-arch1.1 (LLVM
18.1.8) device-ID: 10005:0000 surfaces: xcb,xlib
Audio:
Device-1: Intel Sunrise Point-LP HD Audio vendor: Lenovo
driver: snd_hda_intel v: kernel alternate: snd_soc_skl,snd_soc_avs
bus-ID: 00:1f.3 chip-ID: 8086:9d71 class-ID: 0403
API: ALSA v: k6.10.10-zen1-1-zen status: kernel-api tools: N/A
Server-1: PipeWire v: 1.2.5 status: n/a (root, process) with:
1: pipewire-pulse status: active 2: wireplumber status: active
3: pipewire-alsa type: plugin 4: pw-jack type: plugin
tools: pactl,pw-cat,pw-cli,wpctl
Network:
Device-1: Intel Ethernet I219-LM vendor: Lenovo driver: e1000e v: kernel
port: N/A bus-ID: 00:1f.6 chip-ID: 8086:15d7 class-ID: 0200
IF: enp0s31f6 state: down mac: <filter>
Device-2: Intel Wireless 8265 / 8275 driver: iwlwifi v: kernel pcie:
gen: 1 speed: 2.5 GT/s lanes: 1 bus-ID: 04:00.0 chip-ID: 8086:24fd
class-ID: 0280
IF: wlp4s0 state: up mac: <filter>
Info: services: NetworkManager, systemd-timesyncd, wpa_supplicant
Bluetooth:
Device-1: Intel Bluetooth wireless interface driver: btusb v: 0.8 type: USB
rev: 2.0 speed: 12 Mb/s lanes: 1 mode: 1.1 bus-ID: 1-7:3 chip-ID: 8087:0a2b
class-ID: e001
Report: btmgmt ID: hci0 rfk-id: 1 state: up address: <filter> bt-v: 4.2
lmp-v: 8 status: discoverable: no pairing: no class-ID: 6c010c
Drives:
Local Storage: total: 238.47 GiB used: 21.4 GiB (9.0%)
ID-1: /dev/nvme0n1 maj-min: 259:0 vendor: Toshiba model: N/A
size: 238.47 GiB block-size: physical: 512 B logical: 512 B speed: 31.6 Gb/s
lanes: 4 tech: SSD serial: <filter> fw-rev: 5111AALA temp: 30.9 C
scheme: MBR
SMART: yes health: PASSED on: 263d 17h cycles: 1,893
read-units: 52,597,179 [26.9 TB] written-units: 25,524,616 [13.0 TB]
Partition:
ID-1: / raw-size: 238.47 GiB size: 238.47 GiB (100.00%)
used: 21.4 GiB (9.0%) fs: btrfs block-size: 4096 B dev: /dev/nvme0n1p1
maj-min: 259:1
ID-2: /home raw-size: 238.47 GiB size: 238.47 GiB (100.00%)
used: 21.4 GiB (9.0%) fs: btrfs block-size: 4096 B dev: /dev/nvme0n1p1
maj-min: 259:1
ID-3: /var/log raw-size: 238.47 GiB size: 238.47 GiB (100.00%)
used: 21.4 GiB (9.0%) fs: btrfs block-size: 4096 B dev: /dev/nvme0n1p1
maj-min: 259:1
ID-4: /var/tmp raw-size: 238.47 GiB size: 238.47 GiB (100.00%)
used: 21.4 GiB (9.0%) fs: btrfs block-size: 4096 B dev: /dev/nvme0n1p1
maj-min: 259:1
Swap:
Kernel: swappiness: 133 (default 60) cache-pressure: 100 (default) zswap: no
ID-1: swap-1 type: zram size: 7.41 GiB used: 0 KiB (0.0%) priority: 100
comp: zstd avail: lzo,lzo-rle,lz4,lz4hc,842 max-streams: 4 dev: /dev/zram0
Sensors:
System Temperatures: cpu: 52.0 C pch: 38.0 C mobo: N/A
Fan Speeds (rpm): N/A
Info:
Memory: total: 8 GiB note: est. available: 7.41 GiB used: 2.69 GiB (36.2%)
igpu: 32 MiB
Processes: 212 Power: uptime: 29m states: freeze,mem,disk suspend: deep
avail: s2idle wakeups: 0 hibernate: platform avail: shutdown, reboot,
suspend, test_resume image: 2.95 GiB services: org_kde_powerdevil,
power-profiles-daemon, upowerd Init: systemd v: 256 default: graphical
tool: systemctl
Packages: pm: pacman pkgs: 1414 libs: 417 tools: octopi,paru Compilers:
gcc: 14.2.1 Shell: garuda-inxi (sudo) default: Bash v: 5.2.37
running-in: konsole inxi: 3.3.36
Garuda (2.6.26-1):
System install date:     2024-04-05
Last full system update: 2024-09-29
Is partially upgraded:   No
Relevant software:       snapper NetworkManager dracut
Windows dual boot:       No/Undetected
Failed units:

I’m trying to run this cronjob entry:

@reboot rclone mount --daemon GDrive:<path> /home/elia/DB

but as I say, when I write the above line into the temporary file (which is opened after “crontab -e” command) and then save it, nothing happens.

Other infos:

sudo crontab -l -u root
no crontab for root

sudo crontab -l -u elia
no crontab for elia

sudo cat /etc/crontab
# /etc/crontab: configuration file for cron

# See cron(8) and crontab(5) for details.

# m h dom mon dow user command

Also, these are journalctl entries for ‘cronie’ service after Garuda boot:

journalctl -u cronie

-- Boot 5b273b8a46c0419ba69c88ed86003029 --
set 29 19:33:06 elia-thinkpad systemd[1]: Started Command Scheduler.
set 29 19:33:06 elia-thinkpad crond[648]: (CRON) STARTUP (1.7.2)
set 29 19:33:06 elia-thinkpad crond[648]: (CRON) INFO (Syslog will be used instead of sendmail.)
set 29 19:33:06 elia-thinkpad crond[648]: (CRON) INFO (RANDOM_DELAY will be scaled with factor 74% if used.)
set 29 19:33:06 elia-thinkpad crond[648]: (CRON) INFO (running with inotify support)
set 29 20:01:00 elia-thinkpad CROND[5065]: (root) CMD (run-parts /etc/cron.hourly)
set 29 20:01:00 elia-thinkpad anacron[5073]: Anacron started on 2024-09-29
set 29 20:01:00 elia-thinkpad anacron[5073]: Will run job `cron.daily' in 49 min.
set 29 20:01:00 elia-thinkpad anacron[5073]: Will run job `cron.weekly' in 69 min.
set 29 20:01:00 elia-thinkpad anacron[5073]: Will run job `cron.monthly' in 89 min.
set 29 20:01:00 elia-thinkpad anacron[5073]: Jobs will be executed sequentially
set 29 20:01:01 elia-thinkpad CROND[5064]: (root) CMDEND (run-parts /etc/cron.hourly)

If I run manually 'rclone mount --daemon GDrive: /home/elia/DB it works as expected.

(Just)

FYI

The default system scheduled jobs in arch linux is managed through systemd.timer. To list the timer units :

systemctl list-timers
3 Likes

If I understand correctly, rclone needs and uses a configuration file, and maybe cron is not able to find it.
So, this might be a problem of environment variables and/or even use the whole path to rclone.
Anyway, this wouldn’t explain why the entry is not saved at all… I have no idea.
In general, to achieve something @reboot, I’d rather create a systemd service running at startup.
You could start with something like this (to be refined for sure):
Create a file in /etc/systemd/system, e.g. rclone-gdrive.service with the following contents:

[Unit]
Description=Rclone Google Drive Mount
Wants=network-online.target
After=network-online.target

[Service]
TimeoutStartSec=10
ExecStart=/usr/bin/rclone mount --daemon GDrive:<path> /home/elia/DB
Restart=always

[Install]
WantedBy=multi-user.target

Then

sudo systemctl enable --now rclone-gdrive.service

Edit: it will be probably a bit more complicated. See e g.

Just found a solution you could start with:

4 Likes

@SGS thank you for the command to list timers, much appreciated.

@filo thank you very much! These are a lot of useful infos and you were right, it was an environment variable issue.

So, I can say for sure that I posted in the right section: I’m such a newbie!

‘crontab -e’ command opens Keta editor 'cause a global environment variable is set to use Keta text editor.

Now the fun part, I come from Debian, where by default you find Bash shell, so… I was trying to use Fish shell as Bash, but this isn’t how things work.

I opened:

~/.config/fish/config.fish

and configured:

set -g EDITOR /usr/bin/nano
set -g SUDO_EDITOR /usr/bin/nano
set -g VISUAL $EDITOR

So this is the Fish shell equivalent of setting environment variables inside ~/.bashrc (on Bash).

I edited crontab -e with ‘nano’, thus the temporary file (crontab.something) acts correctly as a buffer, inside I wrote:

@reboot rclone mount --daemon GDrive: /home/elia/DB/

Saved with Ctrl + X and reboot.

My Google Drive was successfully mounted at boot.

This lookslike to me a little bit “dirty” as solution, so I’ll definitively give a try to the systemd service way you pointed me. For now, a big thank you!

2 Likes

Well done! Hey, I forgot the most important thing: welcome to the forum! :wink:

2 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.