adding a user to cron.allow


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting adding a user to cron.allow
# 1  
Old 03-05-2009
adding a user to cron.allow

Hello all,

I have solaris 10. I have have a script that installs crontab for a user. I want to add some more features to this script.

I want to check whether the user exists in etc/cron.d/cron.allow ... if yes then continue the script without adding .... if not, then add that user to the cron.allow.

Can any of you gurus out there help a newbie like me ?

Thanks.

MisterKhan
# 2  
Old 03-05-2009

Code:
user=whoever
grep "$user" etc/cron.d/cron.allow >/dev/null ||
  echo "$user" >> etc/cron.d/cron.allow

# 3  
Old 03-05-2009
Thanks a lot for this.
# 4  
Old 03-05-2009
What scripting language/shell are you using?
# 5  
Old 03-05-2009
You may want to grep for "^${user}$". "whoever" would match "whoeverr" or "iwhoever".
# 6  
Old 03-06-2009
@dirk.diaglaow

I am using "ksh".

I didn't quite understand your second post.... should I just type ^${user}$ as it is ... because ^ can also be obtained by pressing ctrl+v .

I thank you for your continuing help.
# 7  
Old 03-10-2009
Thanks guys ...

wonderful suggestions .... hats off to the gurus
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Adding a cron job that will execute everyday at 14:50 hrs

Hi I want to execute a cron job everyday at 14:50 hrs. I have a script like this: TMP_FILE="/tmp/tmpcron.txt" RES=0 /usr/bin/crontab -l >> $TMP_FILE ADD_JOB="50 14 * * * /opt/mypath/scriptname.sh" grep "scriptname.sh" $TMP_FILE >> /dev/null JOB_NOT_EXIST=$? if test $JOB_NOT_EXIST... (2 Replies)
Discussion started by: saurabhkoar
2 Replies

2. Shell Programming and Scripting

Does running a cron job of a user require the user to be logged in?

Suppose user 'asdf' is not logged into server 'bbbb', but the server is up. User 'asdf' has cron job. Will it be executed? (1 Reply)
Discussion started by: thulasidharan2k
1 Replies

3. Shell Programming and Scripting

Adding a new root cron job

Hi there, I have over 2000 systems (mainly Solaris) and I want to write a script that inserts a new root cronjob on each of those servers. obviously just adding a line to /var/spool/cron/crontabs/root looks like the easiest way, but i really dont want to have to send a HUP to crond on all boxes ... (3 Replies)
Discussion started by: rethink
3 Replies

4. Solaris

User entry in both cron.allow and cron.deny

Hello All, Anybody please help me to know ,what happens when a user having entry in both cron.allow and cron.deny files.Wheather the user will be able to access the crontab??? Thanks in advance Vaisakh (5 Replies)
Discussion started by: ksvaisakh
5 Replies

5. UNIX for Dummies Questions & Answers

cron-apt - adding X-headers

Hi, We use a ticket system for our IT queries called OTRS. Emails sent to that system are placed in ticket queues. OTRS reads X- headers in emails as described here: http://dev.jasonpruim.com/otrs/doc/X-OTRS-Headers.txt We would like to be able to configure cron-apt to place certain X-... (1 Reply)
Discussion started by: karuna
1 Replies

6. Solaris

Adding user

Hello All, New to Solaris, I added a new user by cmd " useradd -d /export/home/username -m username " but wondered when I tried to login with this new username, It doesn't automatically redirect to the user's home folder. Can anyone suggest about this? (9 Replies)
Discussion started by: naw_deepak
9 Replies

7. Solaris

help adding a new user/password

I just installed Solaris 10 yesterday and I need to create a new username and password. I'm new to the system and I have yet to learn my way around. I appreciate all help and thank you in advance. (5 Replies)
Discussion started by: bones
5 Replies

8. SCO

adding a user

In SCO Unix, where does useradd or adding a user through scoadmin (gui) pick the initial default .profile (login profile) that is put in the users home folder? In Solaris its in the /etc/skel/.profile. I would like to replace it with a custom .profile; so that it's picked automatically when... (1 Reply)
Discussion started by: othman
1 Replies

9. Shell Programming and Scripting

adding date to cron log

Hi. I'm trying to output the current date to a cronjob log file. Nothing seems to work, echo $(date), echo `date` or just date in the script. I'm using /sbin/sh Any ideas? Thanks, John (2 Replies)
Discussion started by: JohnH
2 Replies

10. Solaris

adding a user in single user mode

Just got a solaris 8 blade 150 box with no users, only a root account. no one seems to know the password. I'd like to add one user. So I booted into single user mode via cdrom and added one. Can't seem to login using the new account, though. Here's what I'm using: # useradd -d /tmp/"user" -m... (1 Reply)
Discussion started by: ECBROWN
1 Replies
Login or Register to Ask a Question