Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cron wont run #827

Open
bladecell opened this issue Feb 6, 2024 · 6 comments
Open

Cron wont run #827

bladecell opened this issue Feb 6, 2024 · 6 comments

Comments

@bladecell
Copy link

Hello, after adding this mod to code-server image and adding the line */5 * * * * /bin/echo test >> /config/tmp.txt to config/crontabs/abs and restarting the container, I would expect the line to appear in file after running crontab -e in docker container, but it is not present. Furthermore no test is appended in /config/tmp.txt so the cron job did not run and other commands in abc file wont run either.

@aptalca
Copy link
Member

aptalca commented Feb 6, 2024

you're likely checking the root user's crontab with that command, but the line is getting added to abc user's

Also, your file needs to be named abc, not abs

@bladecell
Copy link
Author

My mistake, the file is named abc, not abs, I am checking crontab like this

crontab -l -u abc
# Edit this file to introduce tasks to be run by cron.
# 
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
# 
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').
# 
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
# 
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
# 
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
# 
# For more information see the manual pages of crontab(5) and cron(8)
# 
# m h  dom mon dow   command

@LinuxServer-CI
Copy link

This issue has been automatically marked as stale because it has not had recent activity. This might be due to missing feedback from OP. It will be closed if no further activity occurs. Thank you for your contributions.

@mindset-tk
Copy link

mindset-tk commented Apr 2, 2024

I'm also having this issue. I've tried adding it to both abc and root crontabs. Both crontabs list correctly when I run the crontab -lu abc and crontab -lu root. But the command never actually runs, unless I manually run crond or similar. I am using the lscr.io/linuxserver/qbittorrent:4.6.3 container.

edit: never mind, it seems to be working on the 4.6.3 container after deleting the image and redownloading.

@acondura
Copy link

acondura commented Apr 14, 2024

True, I'm also having this problem. I have added DOCKER_MODS=linuxserver/mods:universal-cron to my docker-compose file, I'm using https://docs.linuxserver.io/images/docker-code-server. I then added a test line in /config/crontabs/abc but nothing works.

The only way I could get it to work is to use a custom script (as outlined here https://www.linuxserver.io/blog/2019-09-14-customizing-our-containers) by adding a volume line like this:

  • ./init:/custom-cont-init.d:ro

and then in my init/cron.sh file write this:

#!/bin/bash
cronjob="YOUR-COMMAND-GOES-HERE"
(crontab -u abc -l; echo "$cronjob" ) | crontab -u abc -

I hope this helps!

@LinuxServer-CI
Copy link

This issue has been automatically marked as stale because it has not had recent activity. This might be due to missing feedback from OP. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Issues
Development

No branches or pull requests

5 participants