Using Cron to make newusers every 10 minutes.
Hi, I am trying to make the crond run a script which is located in my home directory every ten minutes. The script as guessed runs the newusers command.
--crontab file for root-- #Create all user accounts in newusers.txt file */10 * * * * /home/karas/userlist 1> /dev/null --userlist file located in my home directory-- #!/bin/bash newusers public_html/newusers.txt echo -n > public_html/newusers.txt Then the new newusers.txt file is in the public_html folder and contains the users to be created. The file is in the correct format as I was able to do the newusers command manually as root and it created the users. But I am stumped as to why the crond does not work. I've had the cron send me emails every 10 minutes just to see that it is working. So I am pretty lost. Thanks in advance. |
Check the execute permission on your script file.
Try to just specify 777 on script file once just to check that there is no permission related issue. Thanks |
No, that doesn't appear to have made any difference. i've made both the userlist script and newusers.txt have permissions of 777, and nothings changed.
|
UPDATE:
OK the cron appears to be executing the userlist file....But it's not making the users in the list, it's just deleting everything in the file. |
Try giving the full path of the newusers command or setting $PATH in your script. cron runs things in a process environment with a limited $PATH as you can demonstrate by modifying your script to echo $PATH to a file.
|
In the cron i've given a full path of /home/karas/userlist
And in the userlist file i've given the full path of /home/karas/public_html/newusers.txt Still no luck. Just deletes the entries without creating a user account. |
You'll also need to give the full path to the /usr/sbin/useradd command (and pretty much every other command too).
|
But I am using newusers? That just takes the contents of a file in the correct format and uses the data to make a new user account? No? :-S
|
Quote:
/usr/sbin/newusers So, make sure you reference it with the /full/path_to/newusers in your crontab |
Quote:
|
Quote:
|
Done that, and got nothing :| Just an empty newusers.txt file.
UPDATE: I got it to do the newusers command and make a new acocunt, however that was only after I commented out the echo -n command.... What is going on :s |
Change your script to:
Code:
#!/bin/bash |
After doing that in the mail for root is the following:
Quote:
|
Did you copy and paste the script exactly? There are only 16 lines there...
|
All times are GMT -5. The time now is 03:25 AM. |