顯示具有 command 標籤的文章。 顯示所有文章
顯示具有 command 標籤的文章。 顯示所有文章

星期四, 8月 09, 2012

Solaris 10 cron job 達到最大限制

/var/cron/log:
root# tail -100 log |more
! c queue max run limit reached Thu Apr 26 09:21:00 2012
! rescheduling a cron job Thu Apr 26 09:21:00 2012
! c queue max run limit reached Thu Apr 26 09:21:00 2012
.
.
.


vi /etc/cron.d/queuedefs
putting an entry like this will bump the limit from 100 to 500:
c.500j2n30w <==此行是手動加上去的 , 改到五百筆

root# svcs -a |grep cron
online Apr_09 svc:/system/cron:default
root# svcadm restart svc:/system/cron:default


星期二, 4月 24, 2012

測試SMTP relay/MAIL server service的方法

telnet smtp_ip 25 <==這邊smtp 使用的預設port 25 , 所以直接針對TCP 25 port 連接

220 mail2000pr1 ready Tue, 24 Apr 20
12 15:19:38 +0800 (CST)
mailfrom:sender@domain.net
500 Command unrecognized.
mail from:sender@domain.net
250 Sender <mvasp@ms.emome.net> OK
rcpt to:receiver@domain.net
250 Recipient <jay.chu@hwacom.com> OK
data ==> 先輸入 data,代表要開始輸入 email 的內容了
354 Enter mail, end <CRLF>.<CRLF>
test from smtp client
. #.作為結尾
250 Message accepted for delivery

在這之後, 就會收到信了~

星期四, 12月 01, 2011

Tru64 cron數量達到最大限制


之前想在客戶的伺服器設定cron table , 但看以下log 發現數量達到最大限制

tail -100 /var/adm/cron/log
--
Tru64 default cron 只有到25個cron job 排程, 可以放大到所需要的量
vi /var/adm/cron/queuedefs
max_jobs=25
log=4

--Restart cron
/sbin/rc3.d/S57cron stop and start

Linux Hard Disk Format Command

Linkto :  http://www.cyberciti.biz/faq/linux-disk-format/


Step #1 : Partition the new disk using fdisk command
Following command will list all detected hard disks:
# fdisk -l | grep '^Disk'
Output:
Disk /dev/sda: 251.0 GB, 251000193024 bytes
Disk /dev/sdb: 251.0 GB, 251000193024 bytes
A device name refers to the entire hard disk. For more information see Linux partition naming convention and IDE drive mappings.
To partition the disk - /dev/sdb, enter:
# fdisk /dev/sdb
The basic fdisk commands you need are:
  • m - print help
  • p - print the partition table
  • n - create a new partition
  • d - delete a partition
  • q - quit without saving changes
  • - write the new partition table and exit

Step#2 : Format the new disk using mkfs.ext3 command

To format Linux partitions using ext2fs on the new disk:
# mkfs.ext3 /dev/sdb1

Step#3 : Mount the new disk using mount command

First create a mount point /disk1 and use mount command to mount /dev/sdb1, enter:
# mkdir /disk1
# mount /dev/sdb1 /disk1
# df -H

Step#4 : Update /etc/fstab file

Open /etc/fstab file, enter:
# vi /etc/fstab
Append as follows:
/dev/sdb1               /disk1           ext3    defaults        1 2
Save and close the file.

Task: Label the partition

You can label the partition using e2label. For example, if you want to label the new partition /backup, enter
# e2label /dev/sdb1 /backup
You can use label name insted of partition name to mount disk using /etc/fstab:
LABEL=/backup /disk1 ext3 defaults 1 2

如何修改hp unix ip

http://bbs.chinaunix.net/viewthread.php?tid=371215

ifconfig有個缺點,他只是用來臨時修改ip、netmask、lan卡狀態的。
當系統重啟後,會失效。
可以在/etc/rc.config.d/netconf中看得出來。

所以網路環境的修改最後是用
1)sam->network and communication -> interface card
2)vi /etc/rc.config.d/netconf
然後重啟init進程使生效
/sbin/init.d/net stop
3、set_parms ip_address……
/sbin/init.d/net start

星期五, 11月 25, 2011

Find 指令教學

如果要刪除某資料夾 /oradb/oradata/arch  底下的log :

先用-ok 選項(不執行) 
find /oradb/oradata/arch -mtime +3 -regex ".*.dbf" -user oracle -type f -ok rm -f {} \;

#delete *.arc before three days ago and user ownership is belong to oracle
再用-exec 實際執行
find /oradb/oradata/arch -mtime +3 -regex ".*.dbf" -user oracle -type f -exec rm -f {} \;

-mtime +3 保留昨天前天大前天的資料

-regex .*.dbf : regular expression ,所有.dbf結尾的檔案

-user oracle : 檔案owner 屬於oracle的檔案

-type f : 檔案屬性為file

-ok : 每找到一個檔案詢問一次,測試用

-exec : 直接執行

-
0 0 * * * /script.sh
0-59 0-23 1-31 1-12 0-6
-

find $ORACLE_HOME/rdbms/audit -mtime +21 -regex ".*.aud" -user oracle -type f -exec rm -f {} \;

-mtime +7 保留七天內檔案 (如只要保留至24hr前 則用-mtime + 1)

-regex .*.dbf : regular expression ,所有.dbf結尾的檔案

-user oracle : 檔案owner 屬於oracle的檔案

-type f : 檔案屬性為file

-ok : 每找到一個檔案詢問一次,測試用

-exec : 直接執行

-
-在比較舊的unix OS ,  find command  , 無法用regular expression
bash-2.05# cat del_aud.sh
find /oracle/rdbms/audit/ aud -mtime +7 -user oracle -type f -exec rm -f {} \;
-
刪除*.dmp , *.log
-找出哪些檔案裡面含有"test"的內容
find /wls11g  -print |xargs grep "test"


find /oracle/rdbms/audit \(-name '*.dmp' -o -name '*.log' \) -mtime 3 -type f -user oracle -exec rm {} \;

-
找出哪些檔案大小超過10M
#20480kblock (512byte/block) = 10MB
find / -type f -size +20480k  -exec ls -l {} \; | awk '{ print $9 "  " $5/1024/1024 " MB"  }'

@solaris OS
find / -type f -size +20480k  -exec ls -lh {} \;


這指令可以找出在 有那些檔案 size > 10MB 的檔案,並搬移到old 資料夾

-trc 檔案搬移之script
mkdir ./old

days="+3"
find ./ -type f -name '*.trc' -mtime $days | \
while read file
do
           mv $file ./old/.
done

#找出某目錄下所有的symbolic link  (包含sub-dir)
find ./ -type l -exec ls -l {} \;

crontab setting

組態檔位置  /var/spool/cron/crontabs/user_name

如果使用者為 root , 則檔案為 /var/spool/cron/crontabs/root
-

例如 , 要在每十分鐘執行/path/to/script.sh 程式:

00,10,20,30,40,50 * * * * /path/to/script.sh >/dev/null 2>&1

cron syntax
*     *     *     *     *  /path/to/script.sh >/dev/null 2>&1
-      -     -      -     -
|       |     |      |      |
|       |     |      |     +-----    day of week (0 - 6) (Sunday=0)
|       |     |     +-------    month (1 - 12)
|       |     +---------    day of month (1 - 31)
|      +-----------    hour (0 - 23)
+-------------    min (0 - 59)


-
Disabling email notifications  >/dev/null 2>&1

By default a cron job will send an email to the user account executing the cronjob. If this is not needed put the following command at the end of the cron job line:

==>以上說明在HP UX 11.31 要特別注意 , 如果server 沒有對外寄信功能,則每天執行的信會queue 住 , 進而耗盡OS記憶體.

如果平常要讓shell script ''background'' 執行結果導向 使其訊息不會被秀出
/path/to/script.sh > /dev/null 2>&1 &

#cronjob log 存放在
 /var/cron/log

awk 如何讓連續的行能相加

-ex.txt
 0.0
 0.0
 24.0
 0.0
 0.0
 0.0
 0.0
 24.0
 0.0
 1.0
 2.0

-output
 48.0
 3.0

use 'awk'

awk '{ if ( $1 == "" ) { printf("%f\n",tot); tot=0 } else tot+=$1 }' ex.txt

LinkWithin-相關文件

Related Posts Plugin for WordPress, Blogger...