As a regular user on Ubuntu 24 is there an alternative to `crontab` to run a command at `@reboot`?
Sep 24, 8:49am
Yes — the main alternative on Ubuntu 24 is a systemd user service (or timer). @reboot in cron is often unreliable anyway, since it runs before the network is up and, for user crontabs, only when the cron daemon decides.
Option 1: systemd user service (recommended)
Create the unit without root:
ini
# ~/.config/systemd/system/mytask.service
[Unit]
Description=Run my command at boot
[Service]
Type=oneshot
ExecStart=/usr/bin/mycommand
[Install]
WantedBy=default.target
Then:
bash
systemctl --user daemon-reload
systemctl --user enable mytask.service
loginctl enable-linger $USER # optional but usually needed
Key point about linger: user services normally only start when you log in. If you want it to run at boot without logging in, run loginctl enable-linger <user> (this one command does require sudo, or another logged-in session's polkit approval).
Option 2: systemd user timer (if you want "shortly after boot" semantics)