cron/system timers within an LXC container

d2600hz

New Member
Mar 12, 2024
7
1
3
So... I can't find any reason for this, but I'm sure someone has.

I've setup a container that does some backup stuff from Github. It worked fine in Linode, and it was running a simple cron to trigger the script.

But I cannot for the life of me get it working within an LXC container. I've tried with cronie and system timers and the thing refuses to run.

It's fully pathed, but is there something I'm missing that enables scheduled events to run in a container? They just won't fire.

Here's what I've tried:

Code:
1 22 * * 1-6 root /usr/bin/tmux new-session -d -s gh-bk-daily '/bin/bash /usr/local/bin/github-backup-daily' 2>&1 >> /var/log/gh-backup-daily.log
0 22 * * 0 root /usr/bin/tmux new-session -d -s gh-bk-weekly '/bin/bash /usr/local/bin/github-backup-weekly'  2>&1 >> /var/log/gh-backup-weekly.log

And systemd timers:


Code:
# /etc/systemd/system/github-daily.timer
[Unit]
Description="Run github-backup-daily every 6 days a week at 22:00"

[Timer]
OnBootSec=5min
OnUnitActiveSec=24h
OnCalendar=Mon..Sat *-*-* 22:00:*
Unit=github-daily.service

[Install]
WantedBy=multi-user.target

# /etc/systemd/system/github-daily.service
[Unit]
Description="Github Daily Backup"

[Service]
ExecStart=/usr/local/bin/tmux-github-daily

Losing my mind here :eek:
 
1) try running this from root's crontab instead of /etc/crontab, and remove the root userid from before the command

2) try running this without tmux

3) inside the github-backup* scripts, define PATH explicitly at the top of the script

4) check journalctl around the time of kickoff for any error messages
 
Thanks,

It is running in roots crontab, I've just been trying everything to make it work.

Thanks for responses, I'll try without tmux as a background task, but one of the tasks can run for almost a day so being able to attach to it to see progress (API limits etc) was important.

Will keep trying.
 
  • Like
Reactions: Kingneutron
> 1 22 * * 1-6 root /usr/bin/tmux

Did you get anywhere with this? If you still have the "root" in the crontab line when it's running from root's crontab, that may be the issue if you tried everything else
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!