LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Enterprise Linux Forums > Linux - Enterprise
User Name
Password
Linux - Enterprise This forum is for all items relating to using Linux in the Enterprise.

Notices

Reply
 
Search this Thread
Old 08-02-2004, 10:14 PM   #1
adrianphicks
LQ Newbie
 
Registered: Aug 2003
Location: Singapore
Posts: 4

Rep: Reputation: 0
How to run useradd from crontab?


We are a school & have built scripts to create users on our student server, & these work fine when run from the command line.

However we have tried several ways to get them to run from the root crontab with no luck. The sticking point seems to be useradd; if I put a simple "useradd testuser" in crontab nothing happens, and if I put the useradd command in a script & run the script using crontab the result is the same.

Any pointers as to why this command won't work from crontab & how to get it working?

Thanks much.


Adrian Hicks
 
Old 08-02-2004, 11:14 PM   #2
osvaldomarques
Member
 
Registered: Jul 2004
Location: Rio de Janeiro - Brazil
Distribution: Conectiva 10 - Conectiva 8 - Slackware 9 - starting with LFS
Posts: 519

Rep: Reputation: 34
Hi Adrian,
The environment which runs under cron is not the same as your session. You have to specify the absolute path of useradd: "/usr/sbin/useradd".
Best regards.
 
Old 08-02-2004, 11:41 PM   #3
adrianphicks
LQ Newbie
 
Registered: Aug 2003
Location: Singapore
Posts: 4

Original Poster
Rep: Reputation: 0
Thanks Osvaldo (hope I got your name right). I've tried that before & had no luck, but have just had success on Debian Sarge where Woody on the student server won't do it.

Will upgrade the student machine to Sarge & go from there.

Adrian Hicks
 
Old 08-03-2004, 12:00 AM   #4
osvaldomarques
Member
 
Registered: Jul 2004
Location: Rio de Janeiro - Brazil
Distribution: Conectiva 10 - Conectiva 8 - Slackware 9 - starting with LFS
Posts: 519

Rep: Reputation: 34
Hi Adrian,
Normally things on the crontab are tested so, all the output of it is redirected to /dev/null. You can debug it by redirecting it to a file; for example
Code:
* * * * * (useradd adrian) >>/tmp/debug-useradd 2>&1
All the messages will be appended to this file in the /tmp directory. As you say you already tried "/usr/sbin" in Woody, it is probable it is in another directory. You can determine the real path with "which useradd" or, in the worst of the hypothesis, "find / -mount -name useradd".
By the way, you got it right.

Osvaldo.
 
  


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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What does the run-parts mean in crontab? mTorbin Linux - Newbie 15 04-27-2012 03:53 PM
want to run program every minute, crontab???? poj Linux - General 4 09-19-2005 04:29 PM
crontab and run-parts gavinbeatty Slackware 4 09-13-2005 06:56 PM
Script doesn't run in crontab dani81 Linux - General 1 11-16-2004 03:42 AM
Can't run F-Prot with Crontab maxflex Slackware 7 07-31-2004 10:11 AM


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

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