A
A
Alexey2013-10-28 12:51:57
Task Schedulers
Alexey, 2013-10-28 12:51:57

Issues with wget in bash script from cron

Good day.
It was necessary to periodically execute the script that worked before manually.
0 */3 * * * root /usr/local/etc/postfix/out/fresh-maps.sh

I placed the fresh-maps.sh script in the /etc/crontab file :

#!/usr/local/bin/bash
USER=login
PASSWORD=pass
DATE=`date "+_%m-%d_%H"`

if [ -s /usr/local/etc/postfix/maps_recipient ] ; then
    cd /usr/local/etc/postfix/out/
    rm -f /usr/local/etc/postfix/out/maps_recipient
    wget --quiet --user=$USER --password=$PASSWORD http://192.168.5.25/postfix/pgg/maps_recipient
    if [ -s /usr/local/etc/postfix/out/maps_recipient ] ; then
        mv /usr/local/etc/postfix/maps_recipient /usr/local/etc/postfix/old/maps_recipient$DATE
        cp /usr/local/etc/postfix/out/maps_recipient /usr/local/etc/postfix/maps_recipient
        postmap /usr/local/etc/postfix/maps_recipient
    fi
fi

Time has passed - according to the logs, the script is being executed. Judging by the files, it reaches wget and stops there.

Tell me what's wrong?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Alexey, 2013-10-28
@capt_Rimmer

Thank you all . Debugging, described by Comrade. sledopit paid off. Everywhere replaced with full paths and double-checked the rights to the files.
Everything is working.

S
Stepan, 2013-10-28
@L3n1n

1. Specify the full path to wget

/usr/bin/wget 


2. Write in the crown
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

D
Dmitry Skogorev, 2013-10-28
@EnterSandman

well, if it’s exactly vget - tell him where to write the file - apparently, he does not have write permissions somewhere
and I would also advise you to use the full paths to the commands both in the script and in the cron - sh /usr/local/…
does the script have execution permissions?

R
rozhik, 2013-10-28
@rozhik

Checklist
1. to make sure that the path contains wget - write the full path to it and to postmap
2. log the output of everything
3. check if the user has write permissions to the corresponding folders.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question