Skip to content

Cronjobs

dickgroenenberg edited this page Nov 5, 2020 · 8 revisions

Issue: virtual env not working in Cron

The cleanup_datasets.py and pgcleanup_datasets.py scripts require the galaxy virtual
environment to be activated (source /home/galaxy/galaxy/.venv/bin/activate)
By default Cron uses /bin/sh which does not support the source command (link).
Moreover these scripts make use of hard-coded relative paths and shoud therefore
be run from /home/galaxy/galaxy
Naturalis_cron.sh is a custom shell script in which all cleanup jobs can be set at once.

To run Naturalis_cron.sh every night at 3 AM:
* 3 * * * /usr/bin/env bash -c 'source /home/galaxy/galaxy/.venv/bin/activate && /home/galaxy/galaxy/cron/Naturalis_cron.sh'

cron syntax summary

list active cronjobs
crontab -l
set or edit current cronjobs
crontab -e
delete cronjobs
crontab -r

Minute Hour Day_of_month Month Day_of_week
* * * * *
cron Test script running every 5 minutes (testing purposes):
*/5 * * * * /path/to/script/Test.sh
cront Test script running 5 minutes past each hour:
5 * * * * /path/to/script/Test.sh

\

Clone this wiki locally