- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Multiple Users Deletion Through Scripts
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2012 12:17 AM - last edited on 11-27-2012 06:37 PM by Maiko-I
11-27-2012 12:17 AM - last edited on 11-27-2012 06:37 PM by Maiko-I
Multiple Users Deletion Through Scripts
Hi Experts
I have a list of users to be deleted in a Server.
I have the file having the list of user list (For eg./tmp/userlist)
My requirement was the script that delete all the users in the specified file .
before that it will check the below points
weather the user in the list exixt or not
Home dir for that user found or not
any cron jobs shedule for the user
I also include the sample commands for that
grep xyz /etc/group
grep xyz /etc/passwd the user must there else exit and print user not found.
ls -ld /home/xyz..
grep xyz /var/adm/cron/cron.allow
ll /var/spool/cron/crontabs/ | grep xyz
crontab -l | grep /home/xyz
Thanks in Advance.
P.S. This thread has been moved from HP-UX > General to HP-UX > Languages - HP Forums Moderator
Ajin.S
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2012 09:17 PM
11-27-2012 09:17 PM
Re: Multiple Users Deletion Through Scripts
>My requirement was the script that delete all the users in the specified file .
A skeleton script would be:
for user in $(< /tmp/userlist); do
# Check existence
id $user > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "User $user not found"
continue
fi
# check home directory
if [ ! -d $(eval echo ~$user) ]; then
echo "User $user has no home directory"
fi
# check crontab
fgrep -q -x $user /var/adm/cron/cron.allow
if [ $? -eq 0 ]; then
echo "User $user in /var/adm/cron/cron.allow"
fi
if [ -f /var/spool/cron/crontabs/$user ]; then
echo "User $user has a crontab"
fi
# ...
done