Linux - GeneralThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
how can I use crontab to add a user?
currently I'm calling a perl script which reads the username from mysql...and does a useradd $username...but it's not working any thoughts?...suggestions?
well...it's just a simple perl script.... I'm not that good at perl so some of you might laugh..but here it goes...this script adds users fine when I run it from command line..but not from crontab...
#!/usr/bin/perl
use strict;
use DBI;
use Data:umper;
########################
# connect to db #
########################
my $db = "db";
my $dbuser= "user";
my $dbpassword = "";
my $hostname = "localhost";
my $dbh = DBI->connect("DBI:mysql:$db:$hostname", $dbuser, $dbpassword);
#lets read the db to see if there's stuff in it
my @arr;
my $query = "select * from user_to_add";
my $sth = $dbh->prepare($query);
$sth->execute();
while(my $hash = $sth->fetchrow_hashref()){
my $x = `userdd $$hash{'username'}`;
push(@arr, $$hash{'username'});
}
$sth->finish();
foreach my $name (@arr){
my $query2 = "delete from user_to_add where username = '$name'";
my $sth2 = $dbh->prepare($query2);
$sth2->execute();
$sth2->finish();
}
$dbh->disconnect();
close(FILE);
Last edited by sizzlingdesi; 11-09-2006 at 04:40 PM.
cause I want this crontab to run every 30 seconds.... and I checked it does execute the script..I printed some crap to STDERR...
You have the same script running twice from what it appears, one every second, the other every 30 seconds with your sleep 30 command. You know, you could just make cron run it every 30 seconds
And I guess I don't understand why you would have this run twice from cron, one missing the day of week..
no there isn't any other errors in the log...and the crond's running too...is there a restriction that cron cannot create a user or something?....maybe not right permission or args?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.