Lukman Prihandika Blog's

Nrimo ing pandum, urip wis ono sing ngatur

Mencatat History di Opensolaris

leave a comment »

Kadang-kadang suatu saat kita ingin melihat lagi perintah-perintah yang pernah kita gunakan di console. Nah, biasanya menggunakan typescript untuk record aktifitas kita namun kendalanya adalah harus mengetikkan command typescript agar menjalankan program tersebut untuk mulai merecord, hal ini kadang-kadang menjadi masalah apabila kita lupa mengetikkan perintah typescript tersebut. Dari kasus diatas kita, kita buat program agar otomatis berjalan saat kita mulai menggunakan mode console. Lalu ikuti langkah-langkahnya berikut ini:

Bentar ini jika default typescript tanpa program,

brokenz@opensolaris:~$ su –
Password:
Sun Microsystems Inc.    SunOS 5.11    snv_111b    November 2008

root@opensolaris:~# script
Script started, file is typescript
root@opensolaris:~# ls -l
total 1
-rw-r–r– 1 root root 0 2009-11-06 10:28 typescript
root@opensolaris:~#

Nah dari command diatas kita lihat bahwa ada file typescript, file ini lah sebenarnya tempat hasil record command kita di simpan. Sekarang ikuti langkah – langkah berikut :

root@opensolaris:~# vi /etc/profile

#####################################################
ACTIVITYDIR=/var/log/activities
if [ ! -d $ACTIVITYDIR ]; then
mkdir -p $ACTIVITYDIR
fi
ACTIVITY=`date +%Y%m%d-%R.%S`-`whoami`
script $ACTIVITYDIR/$ACTIVITY.log 2>&1 /dev/null
#####################################################

bikin direktori activities di /var/log/activities :

root@opensolaris:~# mkdir /var/log/activities

buat ACL direktori activities menjadi 777 yang berarti all user bisa read write and execute :

root@opensolaris:~# chmod -R 777 /var/log/activities/

Sekarang kita keluar dari mode user root :

root@opensolaris:~# exit
exit
Script done, file is typescript
root@opensolaris:~#

kita coba masuk lagi ke user root :

root@opensolaris:~# su –
Sun Microsystems Inc.    SunOS 5.11    snv_111b    November 2008
Script started, file is /var/log/activities/20091106-10:50.54-root.log

Secara otomatis history akan tersimpan di file :

/var/log/activities/20091106-10:50.54-root.log

dan cobalah dengan bermain-main command, jika sudah selesai ketik exit lalu lihat isi file /var/log/activities/20091106-10:50.54-root.log :

root@opensolaris:~# exit
exit
Script done, file is /var/log/activities/20091106-10:50.54-root.log

Dibawah ini hasil record kita :

root@opensolaris:~# cat  /var/log/activities/20091106-10:50.54-root.log
Script started on Fri Nov 06 10:50:54 2009
root@opensolaris:~# ls -l
total 19
-rw-r–r–   1 root     root        8942 Nov  6 10:49 typescript
root@opensolaris:~# cat  /var/log/activities/20091106-10:50.54-root.log
root@opensolaris:~# ps
PID TTY         TIME CMD
1002 pts/3       0:00 bash
1013 pts/3       0:00 ps
root@opensolaris:~# df -a
/                  (rpool/ROOT/opensolaris): 5081851 blocks  5081851 files
/devices           (/devices          ):       0 blocks        0 files
/dev               (/dev              ):       0 blocks        0 files
/system/contract   (ctfs              ):       0 blocks 2147483614 files
/proc              (proc              ):       0 blocks    29901 files
/etc/mnttab        (mnttab            ):       0 blocks        0 files
/etc/svc/volatile  (swap              ):   91080 blocks   288497 files
/system/object     (objfs             ):       0 blocks 2147483423 files
/etc/dfs/sharetab  (sharefs           ):       0 blocks 2147483646 files
/lib/libc.so.1     (/usr/lib/libc/libc_hwcap1.so.1): 5081851 blocks  5081851 files
/dev/fd            (fd                ):       0 blocks        0 files
/tmp               (swap              ):   91080 blocks   288497 files
/var/run           (swap              ):   91080 blocks   288497 files
/export            (rpool/export      ): 5081851 blocks  5081851 files
/export/home       (rpool/export/home ): 5081851 blocks  5081851 files
/export/home/brokenz(rpool/export/home/brokenz): 5081851 blocks  5081851 files
/rpool             (rpool             ): 5081851 blocks  5081851 files
/net               (-hosts            ):       0 blocks        0 files
/home              (auto_home         ):       0 blocks        0 files
root@opensolaris:~# cat  /var/log/activities/20091106-10:50.54-root.log
root@opensolaris:~# exit
exit

script done on Fri Nov 06 10:52:40 2009
root@opensolaris:~#

Semoga bermanfaat🙂

Written by brokenz1

November 6, 2009 at 3:57 am

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: