Hello
The following script runs fine when ran manually (as root), but it fails writing a file into /usr/share/nginx/acme/stuff/.
Here's the script:
Code:
/etc/cron.hourly# cat download_bash
#!/bin/bash
SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
OUTPUT=/usr/share/nginx/acme/stuff/index.html
#This file is successfully created
echo "cron job running at `date`" > /tmp/testcron
NOW=$(date +"%A %d-%m-%Y %T")
echo "$NOW" > $OUTPUT
#No trace of this file in $OUTPUT :-/
wget -i list.txt -qO - | grep -Pzo 'some.pattern' >> $OUTPUT
sed -i 's@/local@http://www.google.com/local@g' $OUTPUT
Here's the destination directory:
Code:
# ll /usr/share/nginx/acme/stuff/
drwxr-xr-x 2 nobody nogroup 4096 Jun 21 14:20 ./
drwxr-xr-x 7 nobody root 4096 May 14 02:08 ../
-rw-r--r-- 1 root root 106640 Jun 21 14:20 index.html
And here's Debian's crontab file:
Code:
# cat /etc/crontab
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# 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 )
Could it be that cron/run-parts doesn't run scripts as root, although that's what it says in /etc/crontab? No information is provided in /var/log/messages.
Thanks for any help.