• 0 Posts
  • 4 Comments
Joined 2 years ago
cake
Cake day: January 26th, 2025

help-circle


  • You have two options that are most likely pre-installed: systemd-timer or cron

    With systemd-timer you can run it as a user or as root. For your use case I would go with the user option for two reasons.

    1. The downloaded files will have the right permissions by default.
    2. Security. There is no reason why the service would need root access to your system.

    For systemd-timer you need two files the .timer and the .system file.

    your-timer.timer

    [Unit]
    Description="Run your-service.service 5min after boot and every 24 hours relative to activation time"
    
    [Timer]
    OnBootSec=5min
    OnUnitActiveSec=24h
    Unit=your-service.service
    
    [Install]
    WantedBy=timers.target
    

    your-service.service

    [Unit]
    Description=Download new podcasts
    
    [Service]
    Type=oneshot
    ExecStart=castget -c
    

    These two files go into ~/.config/systemd/user/. Then run systemctl --user daemon-reload and systemctl --user enable your-timer.timer --now. If you want the service to also run if you are not logged in run sudo loginctl enable-linger youruser.

    For cron it is less work. Just run cron -e and put your command in there preceded by the time it is supposed to run. The timeformat should be explained at the top of the file. I also don’t know if it will run if you are not logged in.