Converting commentary into an answer.
What is the PATH
supplied to your cron
job? Where is chpasswd
stored? Since the directory where chpasswd
is stored is not listed in the path provided by cron
, it fails to find it. You get a very limited environment with cron
; running anything the least out of the ordinary means great care is required.
Either set PATH more fully in the script run by the cron
job, or specify the absolute pathname of the commands that are not in /bin
or /usr/bin
.
Incidentally, how do you set P
for echo
to echo it? Doesn't it set the same value each month? Is that wise?
There are numerous other questions on Stack Overflow about difficulties running commands from cron
jobs. Amongst others, see Bash script not running in cron
correctly and Perl script works but not via cron
and Is there a special restriction on commands executed by cron
?, to name but three.