LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 11-04-2009, 05:15 PM   #1
tifoso
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, 06:15 PM   #2
lumak
Member
 
Registered: Aug 2008
Location: Phoenix
Distribution: Arch
Posts: 799
Blog Entries: 32

Rep: Reputation: 109Reputation: 109
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.
 
Old 11-05-2009, 04:36 AM   #3
tifoso
LQ Newbie
 
Registered: Nov 2009
Posts: 3

Original Poster
Rep: Reputation: 0
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!
 
Old 11-05-2009, 06: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
 
  


Reply


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 12 09-22-2008 11:04 PM
cron job as a non-privileged user do not run chakkerz Linux - General 5 06-03-2008 08:28 PM
Can't get a cron job to run derzok Linux - General 10 12-16-2007 04:00 AM
How to create a cron job to delete a folder's contents? s0n|k Linux - Newbie 1 10-05-2007 07:59 AM
Did my Cron job run? ryedunn Linux - Newbie 2 02-25-2004 08:59 AM


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

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