0👍
Finally after pulling out my hair for several days, I found the working solution.
- I login to server using putty (SSH)
- Type commmand:
crontab -e
- You will see the list of crontab jobs
-
Add my job directly, I typed:
0 3 * * * cp -pRu /home/path/to/my/project/file_dir /home/path/to/my/backup/dir
This will only copy new file/dir based on timestamps in file_dir to backup_dir everyday at 3 am
- After finished type, press ESC, then CTRL+x, it will ask you want to save, just type Y then hit ENTER to save the file.
- Check all the crontab job by type:
crontab -l
- That’s it! Cheers man!
Hopefully, it helps someone who got similar problem 😀
PS: thanks to Igor and zsquare as well.
1👍
The cronjobs you schedule in your settings are not actually added to the crontab until you run python manage.py crontab add
.
- [Answered ]-Having a django model which can belong to either of two other models (foreign key relation)
- [Answered ]-How do I include static files from django installed packages?
- [Answered ]-Empty CharField with null=True returns NoneType Django 1.8
- [Answered ]-Django rest framework custom serializer using foreign key
- [Answered ]-Django – submit multiple forms in a view
1👍
See the format of django crontab:
#format 1
required: cron timing (in usual format: http://en.wikipedia.org/wiki/Cron#Format)
required: the python module path to the method
optional: a job specific suffix (f.e. to redirect out/err to a file, default: '')
#format 2
required: cron timing (in usual format: http://en.wikipedia.org/wiki/Cron#Format)
required: the python module path to the method
optional: list of positional arguments for the method (default: [])
optional: dict of keyword arguments for the method (default: {})
optional: a job specific suffix (f.e. to redirect out/err to a file, default: '')
In both cases you need to use python methods, not just commands from the shell.
You are not allowed to write something like ‘cd …; ./command’; you should wrap this line into python module in your code.
More on it: