LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   How to create user account with a 'newusers' run from a cron job? (https://www.linuxquestions.org/questions/linux-general-1/how-to-create-user-account-with-a-newusers-run-from-a-cron-job-766914/)

tifoso 11-04-2009 05:15 PM

How to create user account with a 'newusers' run from a cron job?
 
How to create user account with a 'newusers' command run from a cron job?

Thank you in advance guys!

lumak 11-04-2009 06:15 PM

First, welcome to LQ!

Second, have you read any of the 'man' pages yet? What distribution are you using? why are you looking to run 'newusers' from a cron job? Is this homework?

A good place to start is:
Code:

man crontab
man crond

Then if you don't understand something, ask about that.

tifoso 11-05-2009 04:36 AM

Hi,

I have got a little project I'm doing, I need to write a bash/php script which creates a linux user, MYSQL database, and emails them of such details. The user accounts should be created with 'newusers' command run from cron job. I read the 'man' pages but still don't know how to do it :/

Thanks!

Wim Sturkenboom 11-05-2009 06:19 AM

And man newusers

Your first step is to define which info is required in a file. As your script is using newusers, I suggest that you keep the format the same as required by newusers. You can use the gecos field to store the email address and database name.
  1. create a script that invokes newusers to add the new user to the system
  2. extend the script to extract the database name and the username from the file
  3. extend the script to use this data to create a database and grant permissions
  4. extend the script to extract the email address from the file
  5. extend the script to mail the file content to the email address
There is a lot of error checking to do (system user already exists, home directory already exists, database already exists, database user already exists, invalid email address)

You can test everything and once you're happy, add it to cron


All times are GMT -5. The time now is 11:02 AM.