I know that my question was asked several times, but there is no solution for my problem. In my Company there is an Application running on a RedHat Mashine. Users connect a text Based GUI via ssh to this Server. This Application does not support Pasword aging resetting password.
I made a script checking password aging time and sending an eMail to each user.
The script is running fine from shell but not working in crontab. Several tests (touch testfile) showed that crontab is working and all scripts are executed. I verified that with a simple echo command at the beginning of the new script.
deeper investigating with several echos showed me that there is a problem with assigning a command to a variable.
This worked for years and in several crontabs
VAR = `ls`
i tested other versions:
VAR = $(ls)
VAR = `/bin/ls`
VAR = $(/bin/ls)
Snippet from Script:
(... generating user/email array ...)
echo "----------------START "$LOGDATE" ---------------" >> $LOGFILE
for ((i=0; i<${#USER[*]} ; i++))
do
USERNAME=${USER[$i]}
EMPFAENGERNAME=${EMPFAENGER[$i]}
TEMP1=`chage -l $USERNAME | grep 'Kennwort läuft ab'|cut -d ":" -f2`
(... sending email to user telling him to change password ...)
Crontab: (root)
00 12 * * 1-5 /root/pw_warning.sh
That script is so simple and its working as root and with sudo, its nothing really complicated but i dont get the point what i am doing wrong.
Update:
Tested PATH=(..) in crontab and in script as suggested. No changes at all.
Again: crontab is working and executing scripts. Every command in the script is working for itself but not when it should be assigned to a variable.
Update2: Adding path to shell did not work:
0 0 * * * /bin/bash /path/to/script.sh
Update3:
Working Workaround:
0 0 * * * ssh root@localhost "/path/to/script"