I'm going to start posting sysadmin-type things on this blog. I haven't done much writing other than technical recently. Posts here will focus on shorter snippets of information that I recently found out and want to pass along (mainly so I remember them myself).
Using @reboot in crontab -e
I recently discovered that the time interval @reboot can be used to start something upon server boot up. An example of this might be some script that you run continuously but that isn't set in /etc/init.d as a service to start on reboot (chkconfig service on). How it would be used is the following:
Let's say I have a script installed onto my machine to log every minute for the load and other processes. It won't restart on server reboot, so I could do the following for it in crontab -e (/var/spool/cron/root):
Grabbing the top level listing of permissions and ownership for a folder
Normally, I'd been using the following for a folder when I only wanted the top-level of the folder:
This would show the full contents of the folder, which I didn't want. A better method would have been to use the -d flag:
To see the difference, here's the returns for /home/admin on my test machine:
This is especially helpful if you want to drill down into folders to see just that folder's set permissions and ownership for any non-working service (like email). Here's an example to see /home/admin/etc/lunaradmin for the machine for each level:
This allows you in one command to get all the necessary permissions in order to troubleshoot if there's something wrong for any of the levels leading into that folder for that domain's passwd file that handles the email user authentication for the domain.
Using @reboot in crontab -e
I recently discovered that the time interval @reboot can be used to start something upon server boot up. An example of this might be some script that you run continuously but that isn't set in /etc/init.d as a service to start on reboot (chkconfig service on). How it would be used is the following:
@reboot command
Let's say I have a script installed onto my machine to log every minute for the load and other processes. It won't restart on server reboot, so I could do the following for it in crontab -e (/var/spool/cron/root):
@reboot nohup ~/pathtoscript &
Grabbing the top level listing of permissions and ownership for a folder
Normally, I'd been using the following for a folder when I only wanted the top-level of the folder:
ls -lh /pathtofolder
This would show the full contents of the folder, which I didn't want. A better method would have been to use the -d flag:
ls -ld /pathtofolder
To see the difference, here's the returns for /home/admin on my test machine:
[root@itchy:/] # ls -lh /home/admin
total 360K
-rw-r--r-- 1 root root 2.8K Oct 28 2009 AccessIds.pm
lrwxrwxrwx 1 admin admin 31 Feb 28 2009 access-logs -> /usr/local/apache/domlogs/admin
drwxr-xr-x 4 admin admin 4.0K May 17 18:01 cpanel3-skel
-rw-r----- 1 admin admin 1 Oct 18 2009 cpbackup-exclude.conf
-rw-r--r-- 1 root root 433 Sep 22 2009 database.yml
drwxr-x--- 6 admin mail 4.0K Jan 28 15:27 etc
drwxrw-rw- 2 admin admin 4.0K Oct 29 2009 happytime
drwxrwx--- 12 admin admin 4.0K May 19 21:15 mail
-rw-r--r-- 1 root root 95K Jan 4 2010 mmangum.txt
-rw-r--r-- 1 dani dani 154K Apr 23 19:27 mysqluser.sql
drwxr-xr-x 2 admin admin 4.0K Jul 5 11:19 perl
-rw-r--r-- 1 admin admin 39K Jul 11 09:52 php.ini
drwxr-xr-x 3 admin admin 4.0K Aug 27 2009 public_ftp
drwxr-x--- 9 admin nobody 4.0K Jul 23 11:16 public_html
-rw-r--r-- 1 root root 13K Oct 28 2009 SafetyBits.pm
drwxr-xr-x 7 admin admin 4.0K Jun 24 18:53 tmp
lrwxrwxrwx 1 admin admin 11 Feb 28 2009 www -> public_html
[root@itchy:/] # ls -ld /home/admin
drwx--x--x 24 admin admin 4096 Jul 11 09:52 /home/admin
This is especially helpful if you want to drill down into folders to see just that folder's set permissions and ownership for any non-working service (like email). Here's an example to see /home/admin/etc/lunaradmin for the machine for each level:
[root@itchy:/] # ls -ld /home/admin /home/admin/etc /home/admin/etc/lunaradmin.com && ls -lah /home/admin/etc/lunaradmin.com/
drwx--x--x 24 admin admin 4096 Jul 11 09:52 /home/admin
drwxr-x--- 6 admin mail 4096 Jan 28 15:27 /home/admin/etc
drwxr-x--- 5 admin mail 4096 Jul 9 12:50 /home/admin/etc/lunaradmin.com
total 44K
drwxr-x--- 5 admin mail 4.0K Jul 9 12:50 .
drwxr-x--- 6 admin mail 4.0K Jan 28 15:27 ..
drwx--x--x 4 admin admin 4.0K Apr 10 15:52 admin
drwx--x--x 3 admin admin 4.0K Apr 10 15:52 cpacct
-rw-r--r-- 1 admin mail 152 Feb 24 13:23 passwd
-rw-r--r-- 1 admin admin 1.9K Feb 24 13:23 passwd,v
drwxr-x--- 2 admin mail 4.0K Feb 24 13:24 @pwcache
-rw-r--r-- 1 admin admin 33 Feb 24 13:23 quota
-rw-r--r-- 1 admin admin 387 Feb 24 13:23 quota,v
-rw-r----- 1 admin mail 107 Apr 10 16:00 shadow
-rw-r----- 1 admin admin 2.0K Feb 24 13:23 shadow,v
This allows you in one command to get all the necessary permissions in order to troubleshoot if there's something wrong for any of the levels leading into that folder for that domain's passwd file that handles the email user authentication for the domain.
Comments