Skip to content

Instantly share code, notes, and snippets.

@jainxy
Last active March 1, 2020 18:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jainxy/a2bb20161d990bae9a95f139b9d49400 to your computer and use it in GitHub Desktop.
Save jainxy/a2bb20161d990bae9a95f139b9d49400 to your computer and use it in GitHub Desktop.
Crontab tricks
=== Use conda environment to run a python script ===
SHELL=/bin/bash
CONDA_PREFIX=/home/code/packages/miniconda3
CONDA_INIT="/home/code/packages/miniconda3/etc/conda/activate.d/proj4-activate.sh"
PYTHON=/home/code/packages/miniconda3/bin/python
12 13 * * * . $CONDA_INIT ; $PYTHON <python file>
=== Use date utility for naming a log file ===
DATEVAR="date +%Y%m%d_%H%M"
17 * * * * echo "logs_$($DATEVAR).txt"
=== Crontab logs ===
sudo cat /var/log/syslog | grep -i cron | grep -i $USER
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment