I am on Debian. I try to make a cron job for youtube-dl. It consists of a daily script, starting at midnight. When I execute the script manually, everything is working perfectly. However, when I use the cron job, I have got an error like this :
ERROR: unable to open for writing: [Errno 13] Permission denied: '/media/Video/...
The cron is the following :
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
@daily /usr/local/bin/youtube-dl-script.sh >> /var/mail/nextcloud 2>&1
I understand, there is a permission issue somewhere, but I don't know how to solve it.
For your information :
- owner/group of the target folder (
/media/Video/
) is :www-data
(owner),wwww-data
(group) - owner/group of the script is :
nextcloud
(owner),root
(group) nextcloud
androot
belong to the groupwww-data
- and the target folder (
/media/Video/
) permission is770
(owner/group group can read/write/execute, others can't do anything).
Please, could you help me ? I have seen a similar topic but the solution was not successful as the problem was not exactly the same. Thank you very much.
EDIT (old status) : so far, I have tried to copy my script (youtube-dl-script.sh
) in /etc/crontab.daily
folder, by respecting the rules (removing the .sh
extension and script owned by root
/ group root
). And checking with cat /etc/crontab
gives me this output :
# m h dom mon dow user command
17 * * * * root cd / && run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
#
So, normally, it should have worked at 6:25 AM this morning, but it didn't !
I have discovered that other scripts have -x
as a final bit, therefore, I have made chmod +x youtube-dl-script
.
Before that, the script is
-rwxr-x--- 1 root root 1682 juin 16 02:24 /etc/cron.daily/youtube-dl-script
.Now, it is
-rwxr-x--x 1 root root 1682 juin 16 02:24 /etc/cron.daily/youtube-dl-script
.
I have now to wait until tomorrow 6:25 AM to see if this works.
EDIT 2 (current status) : so it doesn't work. I have even made chmod 755
in order to have the same persmissions as all other scripts, and I have reboot the server, but it does not work.
What is very strange is that if I do run-parts --test /etc/cron.daily
, my script is listed so it should be runned by cron.daily
Please, if you have any idea, feel free to inform me. Thank you.
/var/spool/cron/crontabs/
. @colbycdev : no because the folder is in an external drive (so it is in /media folder mandatory). Thank you both, please feel free to help me !/etc/cron.daily
, its name must conform to the rules described inman run-parts
(in particular, it cannot have a.sh
or any other "dot extension") and it must be owned byroot
. See theDEBIAN_SPECIFIC
section ofman cron