jgeusebroek / docker-spotweb

A docker image running ubuntu/20.04 Linux and Spotweb
47 stars 27 forks source link

Daily cronjob not working? #64

Closed Larsvb0 closed 7 months ago

Larsvb0 commented 7 months ago

Hi I added the line as per the manual: -e 'SPOTWEB_CRON_RETRIEVE=/15 *' \

this works. Every 15 minutes spotweb updates.

If I change it to -e 'SPOTWEB_CRON_RETRIEVE=/30 ' \
or -e 'SPOTWEB_CRON_RETRIEVE=
/45 ' \
it works as well.

If I want it to update daily at a specific time it does not work. For example: -e 'SPOTWEB_CRON_RETRIEVE=30 13 *' \ Nothing happens at 13:30

Console: root@spotweb:/# crontab -l 30 13 * su -l www-data -s /usr/bin/php /var/www/spotweb/retrieve.php >/var/log/stdout 2>&1 root@spotweb:/# date Sun Jan 14 13:21:13 CET 2024

I used https://crontab.guru/#30_13_*_*_* for the expression.

any ideas?

jgeusebroek commented 7 months ago

Maybe the timezone is different in de docker container?

Larsvb0 commented 7 months ago

I am adding this: e 'TZ=Europe/Amsterdam' \

console returns this: root@spotweb:/# date Sun Jan 14 13:21:13 CET 2024

This should be ok right?

jgeusebroek commented 7 months ago

Yes that should be correct. Weird, I don't have an explanation. Is there a /var/log/cron? TBH I don't use the cron feature myself. I run cron on the host.

*/15 * * * * docker exec spotweb su -l www-data -s /usr/bin/php /var/www/spotweb/retrieve.php >/dev/null 2>&1

Larsvb0 commented 7 months ago

Ok let me try that

Larsvb0 commented 7 months ago

weird, If i run this on the host nothing happens:

/1 * docker exec spotweb su -l www-data -s /usr/bin/php /var/www/spotweb/retrieve.php >/dev/null 2>&1

running crontab -l gives me No crontab for User

How do I configure this?

Larsvb0 commented 7 months ago

nevermind I got it I had to enable crontab for the user first.

Here are the steps: crontab -e choose 2

install Vim using: sudo apt-get update sudo apt-get install vim

crontab -e add this line: /15 * docker exec spotweb su -l www-data -s /usr/bin/php /var/www/spotweb/retrieve.php >/dev/null 2>&1 hit ESC, type :x to save the file