LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 11-14-2007, 10:43 AM   #1
Roosta21
Member
 
Registered: Aug 2004
Distribution: Fedora core 4
Posts: 55

Rep: Reputation: 15
Command not working in cron job, but works fine in root


Hi I am running the jailkit which creates a chroot environment and chroots users.. The jail command works fine in command line.. but when i attempt run it in a cron it does not work/jail correctly

the cronjob is here
Code:
*/1 * * * *  /usr/sbin/jk_jailuser -v -m -j /var/www/vhosts/mydomain.com/web_users unn_testjail5 >> /tmp/outputnew.log 2>&1
and below is the output

Code:
sh: usermod: comnd not found
adding user unn_testjail5 to /var/www/vhosts/mydomain.com/web_users/etc/passwd with shell /usr/sbin/jk_lsh
adding group unn_testjail5 to /var/www/vhosts/mydomain.com/web_users/etc/group
modify user unn_testjail5; dir /var/www/vhosts/mydomain.com/web_users/./home/unn_testjail5 and shell /usr/sbin/jk_chrootsh
failed to execute usermod -d /var/www/vhosts/mydomain.com/web_users/./home/unn_testjail5 -s /usr/sbin/jk_chrootsh unn_testjail5
failed to modify user unn_testjail5
Moving files from /home/unn_testjail5 to /var/www/vhosts/mydomain.com/web_users/./home/unn_testjail5
Creating directory/var/www/vhosts/mydomain.com/web_users/./home/unn_testjail5
Copying /home/unn_testjail5/.bashrc to /var/www/vhosts/mydomain.com/web_users/./home/unn_testjail5/.bashrc
Copying /home/unn_testjail5/.bash_profile to /var/www/vhosts/mydomain.com/web_users/./home/unn_testjail5/.bash_profile
I seems that the usermod is the problem but im not sure how to solve the problem

Last edited by Roosta21; 11-14-2007 at 11:21 AM.
 
Old 11-14-2007, 11:06 AM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,973
Blog Entries: 11

Rep: Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879
Is it called from with the script? Use the full path
in the script, not just the name.


Cheers,
Tink
 
Old 11-14-2007, 11:21 AM   #3
Roosta21
Member
 
Registered: Aug 2004
Distribution: Fedora core 4
Posts: 55

Original Poster
Rep: Reputation: 15
The above command was in a perl script that didn't jail the user properly when running form a cron.. (although the script jailed the user fine if it was run from the command line) I then took the command in question out and tried to run it individually in the crontab


*/1 * * * * /usr/sbin/jk_jailuser -v -m -j /var/www/vhosts/mydomain.co.uk/web_users unn_testjail5 >> /tmp/outputnew.log 2>&1


and it produced the above errors..

Im newbie could you expand on what you were saying
 
Old 11-14-2007, 11:25 AM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,973
Blog Entries: 11

Rep: Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879
Well ... since there's no mention of usermod in the cron-command
I'm assuming that jk_jailuser is a script. Now if you execute a
script from cron chances are high that the path doesn't match the
path in your login-shell. To mitigate that I suggest that you
edit the script and replace the spot where usermod is invoked with
a "magic incantation" that uses the full path to usermod.

Alternatively you could modify crons settings to be like the root
environment settings. But method one is cleaner (and safer).



Cheers,
Tink
 
Old 11-22-2007, 08:08 AM   #5
Roosta21
Member
 
Registered: Aug 2004
Distribution: Fedora core 4
Posts: 55

Original Poster
Rep: Reputation: 15
Brilliant that worked great i added the path to the cron job.. and it all jails fine now through the 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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
cron job not working bittus Linux - Software 7 04-27-2009 07:39 PM
Script works when run manually but not in cron job Harlin Linux - Software 7 10-16-2007 06:36 PM
Cron Job Not Working... ALInux Linux - Software 2 07-24-2007 04:15 AM
cron job and boot command Thulemanden DamnSmallLinux 3 11-08-2006 12:22 AM
Cron Job help...how to write this command? pxumsgdxpcvjm Linux - Newbie 2 09-05-2006 04:42 AM


All times are GMT -5. The time now is 12:58 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