Helmonder Posted January 6, 2018 Share Posted January 6, 2018 How do i enable a crontab job in a docker ? I need to have my spotweb docker refresh every hour.. I can give the command manually from console.. In a VM I can do this , I can also do it in unraid itself, setting it up in the GO file, but I am unsure how to do this in a docker and having it survive a reboot. Quote Link to comment
Squid Posted January 6, 2018 Share Posted January 6, 2018 7 hours ago, Helmonder said: I can give the command manually from console 7 hours ago, Helmonder said: I can also do it in unraid itself, setting it up in the GO file Probably the best option, or via user scripts. Any changes (adding a cronjob) within the image will get lost if/when the container gets updated Quote Link to comment
Helmonder Posted January 6, 2018 Author Share Posted January 6, 2018 But how though.. I can set a cron job to run through the go file for unraids own environment, but how do i do it for the environment of a docker ? Quote Link to comment
Squid Posted January 7, 2018 Share Posted January 7, 2018 21 hours ago, Helmonder said: But how though.. I can set a cron job to run through the go file for unraids own environment, but how do i do it for the environment of a docker ? you would set up your script to be something like docker exec -t NameOfContainer CommandToRun Quote Link to comment
Helmonder Posted January 8, 2018 Author Share Posted January 8, 2018 Thanks... Have to do a bit more digging... In my spotweb container there is no CRON present.. So I would have to make a script executed via the GO as follows: apt-get update apt-get -y install cron Then something that puts the following line in cron from commandline: @hourly /usr/bin/php /var/www/spotweb/spotweb/retrieve.php Then I would have to make sure that the docker is running when the GO file is executed.. Possibly work with a pause in there.. Quote Link to comment
Dikkekop Posted March 6, 2019 Share Posted March 6, 2019 (edited) i have spotweb running in the "nginx" docker with the database on the "mariadb" docker. The "nginx" docker has cron buildin Addad the following user script on unraid: Download "CA User Scripts" from CA. Go to Settings --> User Scripts --> ADD NEW SCRIPT. add a script name for example "update spotweb" click on the newly created user script named: update sportweb (blue text) and click "Edit Script" remove all text and paste this: #!/bin/bash docker exec -t nginx php /config/www/spotweb/retrieve.php > /dev/null /config/www/spotweb/retrieve.php is the path to the retrieve.php file from within the docker container. Click SAVE CHANGES and set Schedule Disabled to Scheduled hourly If you do this the script "update spotweb" (the cronjob) survives an update of the "nginx" docker. Out of curiosity in what docker are you running spotweb ? Edited March 6, 2019 by Dikkekop Quote Link to comment
Helmonder Posted March 22, 2019 Author Share Posted March 22, 2019 That post was a blast from the past.. Things have been running for over a year. At the moment I am using jgeusebroek/spotweb for spotweb. I was using the MySQL docker as a datebase but at some point it failed and I switched to the Postgres11 docker (postgres:11) which now works fine. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.