I have a .sh file (lets say adduser.sh) that is executed via a cronjob that contains the commands to create an FTP user.
The adduser.sh file looks like so…
#!/bin/bash
mkdir /var/www/vhosts/domain/path;
useradd -d /var/www/vhosts/domain/path -ou <uid> -g <group> -s /bin/false <username>;
echo <password> | passwd <username> --stdin;
Now here is my problem. If I run it directly through SSH using…
sh adduser.sh
…no problems and it works as intended.
But if I let the cronjob run it the directory is created but the user is not added.
What gives?
I have resolved this simply adding /usr/bin/ to the useradd function.
Thanks everyone for helping me get on the right track. Hope this helps someone out there.