Monday, September 15, 2008

One-time scheduling of tasks with 'at'

cheduling services with cron and similar tools is great for repetitive tasks but inconvenient for one-time jobs that only need to be accomplished once. For those tasks, use the 'at' command.

At will execute a command at a particular time and is extremely useful for one-time jobs. For instance, if you are running a script or program and want to receive an e-mail when it's done, or need to schedule a job or task for a particular time or date, at will take care of it for you.

For instance, if you wanted to use at to schedule a job to run at 10:00 p.m., you would use:

$ at 10pm -f script

At uses a very useful time specification that will permit you great flexibility with scheduling. To schedule a job for 2:00 a.m. tomorrow, use:

$ at 2am tomorrow -f script

It can also schedule jobs relational to the current time. For instance, to run a job in exactly three hours, use:

$ at now + 3 hours -f script

When scheduling a command with at, it will print out what the job number is and when it will be executed. To view currently scheduled jobs, use the atq command:

$ atq
154    2008-08-04 20:31 a vdanen

To delete a currently scheduled job, use atrm and provide it the job number:

$ atrm 154

Commands can also be provided to at using standard input, or they can be specified by using the -f option, which takes the script or command to run as the argument.

Another way of scheduling jobs with at can be done using the batch command. This will execute a command when the system load average drops below a certain value, usually 0.8 by default. The batch command takes most of the same arguments as at (less a time specification), and is useful for telling the system to execute a new command after currently running processes--that are using large amounts of processing power--are complete.

Finally, at can be restricted to specific users by using the /etc/at.allow and /etc/at.deny files. If at.allow exists, only users listed in the file may use it. If at.deny exists, but at.allow does not, then all users may use at other than those listed in at.deny. By default, any user may use at.

The at command probably isn't something that will be used on a daily basis, but it is useful when certain tasks need to be executed at certain times, regardless of whether you are in front of the computer or not. If nothing else, it makes a great poor man's TO-DO reminder in that you can use it to send an e-mail or SMS message at specific times, as a reminder for certain events.

Sunday, September 14, 2008

硬盘与闪存的IO性能

闪存主要的操作性能特征是随机读和顺序读一样快,但随机写很慢。作者给了一个典型的闪存与硬盘读写性能对比,闪存是随机读为0.4ms,随机写是 48ms,相对来说硬盘随机读是9.6ms,随机写是4.9ms,也就是随机读闪存性能是硬盘的24倍,但随机写硬盘却是闪存性能的10倍。

Wednesday, September 10, 2008

timing of shrink database vs shrink datafile

I have a sql server 2005 database with single data file and transaction log. The data file size is 40Gb and there is 23Gb free space.
So I want to shrink it by click "shrink database". By the help of belw sql, it only completed 50% even after running 3.5 hours.
select percent_complete, estimated_completion_time, cpu_time, total_elapsed_time, * from sys.dm_exec_requests;

I decide to stop it and change to use "shrink file". Surprising, it completed less than 1 minutes and return 7Gb to disk space.

Funny.

Monday, September 08, 2008

check current redo log file usage

-- Percentage full of the current redo log file.
SELECT ROUND((cpodr_bno/lesiz),2)*100||'%' PctCurLogFull
FROM X$kcccp a, X$kccle b
WHERE a.cpodr_seq = leseq;
PCTCURLOGFULL
---------------
35%

Tuesday, September 02, 2008

7 Interview Questions

如何诊断PGA设定是否合适

A good article from ITPUB about PGA diagnosis

using sysdba for exp/imp

notice that there is one space after slash inside the single quote.
imp userid='/ as sysdba' full=y log=d:\sysfull.txt file=d:\back\sysfull.dmp