Skip to content

Instantly share code, notes, and snippets.

@Harshakvarma
Created July 2, 2018 01:18
Show Gist options
  • Select an option

  • Save Harshakvarma/ec2bda70fd6fd213b1274d8936f0dfbd to your computer and use it in GitHub Desktop.

Select an option

Save Harshakvarma/ec2bda70fd6fd213b1274d8936f0dfbd to your computer and use it in GitHub Desktop.
Crontab simplest test

Sample crontab

https://crontab.guru/ - online crontab generator

  1. Empty temp folder every Friday at 5pm
# ┌───────────── minute (0 - 59)
# │ ┌───────────── hour (0 - 23)
# │ │ ┌───────────── day of month (1 - 31)
# │ │ │ ┌───────────── month (1 - 12)
# │ │ │ │ ┌───────────── day of week (0 - 6) (Sunday to Saturday;
# │ │ │ │ │                                       7 is also Sunday on some systems)
# │ │ │ │ │
# │ │ │ │ │
# * * * * *  command_to_execute
  0 5 * * 5 rm -rf /tmp/*
  1. Backup images to Google Drive every night at midnight
0 0 * * * rsync -a ~/Pictures/ ~/Google\ Drive/Pictures/
# Simplest test to crontab
16 21 * * * touch /home/ubuntu/twittercode/cron_testing.txt
# Shell script
16 21 * * * /bin/bash /home/ubuntu/SOME_PROJECTT/SHELL_FILE.sh >> /home/ubuntu/logs/cronjob.log 2>&1
# Python script
00 22 * * * nohup /home/ubuntu/anaconda3/bin/python /home/ubuntu/SOME_PROJECTT/PYTHON_FILE.py > /home/ubuntu/logs/python_cronjob.log 2>&1 &
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment