Skip to content
This repository has been archived by the owner on Sep 15, 2024. It is now read-only.

Fix cron: add cron task only once and start cron service #92

Closed
wants to merge 4 commits into from

Conversation

YannickR26
Copy link

Fix:

  • the cron service was not started at startup
  • allows to leave the environment variable DOLI_CRON at 1

@tuxgasy
Copy link
Owner

tuxgasy commented Aug 27, 2022

If you change DOLI_CRON_KEY or DOLI_CRON_USER, the cron task will not be updated.

@YannickR26
Copy link
Author

Yes, its true, we can update the cron task at each run if you prefer ?

@tuxgasy
Copy link
Owner

tuxgasy commented Aug 29, 2022

Currently, the cron file is already regenerated at each run.

@YannickR26
Copy link
Author

ok, I updated the docker-run.sh file to check the environment variables and create the cron job at each run.

Comment on lines +245 to +248
# Remove old file
if [[ -f ${DOLI_CRON_FILE} ]]; then
rm -rf ${DOLI_CRON_FILE}
fi
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not necessary because the content will be overwritten by the first echo.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's true! It was just to be clearer

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't have to delete it only if it is there, you don't have to test, you can do rm -rf ${DOLI_CRON_FILE} without the if.

echo "*/5 * * * * www-data /var/www/scripts/cron/cron_run_jobs.php ${DOLI_CRON_KEY} ${DOLI_CRON_USER} > /var/www/documents/cron_run_jobs.php.log 2>&1" >> /etc/cron.d/dolibarr
cron -f
exit 0
DOLI_CRON_FILE=/etc/cron.d/dolibarr
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if it's really necessary to create a variable for that.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is to be cleaner !

@@ -198,7 +198,7 @@ function run()
initDolibarr
echo "Current Version is : ${DOLI_VERSION}"

if [[ ${DOLI_INSTALL_AUTO} -eq 1 && ${DOLI_CRON} -ne 1 && ! -f /var/www/documents/install.lock && ${DOLI_DB_TYPE} != "pgsql" ]]; then
if [[ ${DOLI_INSTALL_AUTO} -eq 1 && ! -f /var/www/documents/install.lock && ${DOLI_DB_TYPE} != "pgsql" ]]; then
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The database update should be done only from the main container.

@tuxgasy
Copy link
Owner

tuxgasy commented Jul 26, 2024

Please open another PR if needed.

@tuxgasy tuxgasy closed this Jul 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants