LinuxQuestions.org
Visit Jeremy's Blog.
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 03-23-2015, 10:48 AM   #1
UNIX Zyklon
LQ Newbie
 
Registered: Jan 2010
Posts: 17

Rep: Reputation: 1
very simple script not working inside crontab


Hello all

i made a simple script that takes users from some domain groups and add them to a local group, when i run it manually it run flawess, but when i set the script to run in the crontab the "for" string doesnt seen to run

Code:
* * * * * /root/add_users.sh


#!/bin/bash
#
#
getent group |awk -F':' '/domain-group-1/{print $4}' > /tmp/users
getent group |awk -F':' '/domain-group-2/{print $4}' >> /tmp/users
getent group |awk -F':' '/domain-group-3/{print $4}' >> /tmp/users


 sed 's/,/\n/g'  /tmp/users > /tmp/users2


for i in `cat /tmp/users2`
do
{
usermod -a -G localgroup $i
}
done
/var/log/cron shows the script as being run every minute
 
Old 03-23-2015, 12:13 PM   #2
linosaurusroot
Member
 
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 982
Blog Entries: 2

Rep: Reputation: 244Reputation: 244Reputation: 244
I'd set the PATH at the start of the script.
 
Old 03-24-2015, 03:47 AM   #3
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,497

Rep: Reputation: 1570Reputation: 1570Reputation: 1570Reputation: 1570Reputation: 1570Reputation: 1570Reputation: 1570Reputation: 1570Reputation: 1570Reputation: 1570Reputation: 1570
Quote:
Originally Posted by linosaurusroot View Post
I'd set the PATH at the start of the script.
Or specify the /full/path/to any commands used in the script.

Last edited by TenTenths; 03-24-2015 at 03:49 AM.
 
  


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
extracting values from web page to simple text file (inside a bash script) ondoho Linux - General 5 06-29-2014 11:51 AM
Shell Script Not Working with crontab Ankush Raj Linux - Newbie 3 10-17-2011 11:10 AM
Runs Multiple shell script inside a main script using crontab srimal Linux - Newbie 4 10-22-2009 06:19 PM
Shell script not working through crontab paragkalra *BSD 1 04-15-2009 12:36 PM
Crontab - unable to run simple script Bono Linux - Server 7 12-28-2008 05:32 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:45 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration