Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 11-04-2009, 06:15 PM   #1
LQ Newbie
Registered: Nov 2009
Posts: 3

Rep: Reputation: 0
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!
Old 11-04-2009, 07:15 PM   #2
Registered: Aug 2008
Location: Phoenix
Distribution: Arch
Posts: 799
Blog Entries: 32

Rep: Reputation: 111Reputation: 111
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:
man crontab
man crond
Then if you don't understand something, ask about that.
Old 11-05-2009, 05:36 AM   #3
LQ Newbie
Registered: Nov 2009
Posts: 3

Original Poster
Rep: Reputation: 0

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 :/

Old 11-05-2009, 07:19 AM   #4
Wim Sturkenboom
Senior Member
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Run cron job in every 20 second ust Linux - Newbie 13 01-15-2015 02:01 PM
cron job as a non-privileged user do not run chakkerz Linux - General 5 06-03-2008 09:28 PM
Can't get a cron job to run derzok Linux - General 10 12-16-2007 05:00 AM
How to create a cron job to delete a folder's contents? s0n|k Linux - Newbie 1 10-05-2007 08:59 AM
Did my Cron job run? ryedunn Linux - Newbie 2 02-25-2004 09:59 AM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:25 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration