I am developing a backup script in my NAS running a docker container. Inside my container I have cron running with this /etc/crontab:
root@backups-nas:/code# cat /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
0 * * * * root /code/backup.sh
I have also installed syslog-ng, so I can look for logs in /var/log/syslog, where my task appears:
root@backups-nas:/code# tail -f /var/log/syslog
==> /var/log/syslog <==
Mar 24 19:00:01 backups-nas CRON[9250]: (root) CMD (/code/backup.sh)
The content of my script is this:
root@backups-nas:/code# cat backup.sh
#!/bin/bash
python3 /code/backup.py all >> /code/log/$(date +\%d-\%m-\%Y).log
But when it's o'clock no new log writter in /code/log/$(date +\%d-\%m-\%Y).log and the task is not completed. If I try to execute manually the line of /etc/crontab it works.
What do you think is happening? Thanks in advance
EDIT:
I edited backup.py, starting like this:
#!/usr/local/bin/python3
from sys import argv
import datetime
If I run the script directly works, but cron doesn't run it, although the line in /var/log/syslog.
python3
interpreter on your system?python3
as the interpreter forbackup.sh
-- something that looks like (and whose filename suggests is) a shell script?