Sunday, February 1, 2015

Useradd to a secondary group and schedule a job

add a new user with id of 520 to the oracle group. Schedule a job to run at 11:20 PM every day which sends an out current filesystem.

crontab -e
20 23 * * * /bin/df -h | mailx -s "Filesystem info" jay



[root@mohan Desktop]# useradd jay
uid=510(jay) gid=511(jay) groups=511(jay)
[root@mohan Desktop]# usermod -aG oracle jay
[root@mohan Desktop]# id jay
uid=510(jay) gid=511(jay) groups=511(jay),510(oracle)
[root@mohan Desktop]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2              18G   13G  3.7G  78% /
tmpfs                 495M  224K  495M   1% /dev/shm
/dev/sda1             283M   54M  215M  20% /boot
/dev/mapper/outLuks   475M  2.3M  448M   1% /opt/outLuks
/dev/mapper/datavg-mylv
                      362M  2.1M  341M   1% /opt/datalv
/dev/sr1              4.4G  4.4G     0 100% /media/CentOS_6.6_Final
/dev/sr0              182M  182M     0 100% /media/CentOS
[root@mohan Desktop]# df -h | mailx -s "Filesystem info" jay
[root@mohan Desktop]# su - jay
[jay@mohan ~]$ mail
Heirloom Mail version 12.4 7/29/08.  Type ? for help.
"/var/spool/mail/jay": 1 message 1 new
>N  1 root                  Sun Feb  1 05:51  26/1056  "Filesysteminfo"
& 1
Message  1:
From root@mohan.expanor.local  Sun Feb  1 05:51:43 2015
Return-Path: <root@mohan.expanor.local>
X-Original-To: jay
Delivered-To: jay@mohan.expanor.local
Date: Sun, 01 Feb 2015 05:51:37 -0800
To: jay@mohan.expanor.local
Subject: Filesysteminfo
User-Agent: Heirloom mailx 12.4 7/29/08
Content-Type: text/plain; charset=us-ascii
From: root@mohan.expanor.local (root)
Status: R

Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2              18G   13G  3.7G  78% /
tmpfs                 495M  224K  495M   1% /dev/shm
/dev/sda1             283M   54M  215M  20% /boot
/dev/mapper/outLuks   475M  2.3M  448M   1% /opt/outLuks
/dev/mapper/datavg-mylv
                      362M  2.1M  341M   1% /opt/datalv
/dev/sr1              4.4G  4.4G     0 100% /media/CentOS_6.6_Final
/dev/sr0              182M  182M     0 100% /media/CentOS

& q

No comments:

Post a Comment