SETLOCAL
set ANT_HOME=d:\shared\apache-ant-1.7.0
set PATH=%ANT_HOME%\bin;%JAVA_HOME%\bin;%PATH%
echo "Finished ant_sean compiling. "
Crontab - Quick reference
Setting up cronjobs in Unix and Solaris
cron is a unix, solaris utility that allows tasks to be automatically run in the background at regular intervals by the cron daemon. These tasks are often termed as cron jobs in unix , solaris.
Crontab (CRON TABle) is a file which contains the schedule of cron entries to be run and at specified times.
Following points sum up the crontab functionality :
1. Crontab Restrictions
2. Crontab Commands
3. Crontab file - syntax
4. Crontab Example
5. Crontab Environment
6. Disable Email
7. Generate log file for crontab activity
8. Next Steps
1. Crontab Restrictions
____________
You can execute crontab if your name appears in the file /usr/lib/cron/cron.allow. If that file does not exist, you can use
crontab if your name does not appear in the file /usr/lib/cron/cron.deny.
If only cron.deny exists and is empty, all users can use crontab. If neither file exists, only the root user can use crontab. The allow/deny files consist of one user name per line.
2. Crontab Commands
__________
export EDITOR=vi ;to specify a editor to open crontab file.
crontab -e Edit your crontab file, or create one if it doesn't already exist.
crontab -l Display your crontab file.
crontab -r Remove your crontab file.
crontab -v Display the last time you edited your crontab file. (This option is only available on a few systems.)
3. Crontab file
___________
Crontab syntax :-
A crontab file has five fields for specifying day , date and time followed by the command to be run at that interval.* * * * * command to be executed
- - - - -
| | | | |
| | | | +----- day of week (0 - 6) (Sunday=0)
| | | +------- month (1 - 12)
| | +--------- day of month (1 - 31)
| +----------- hour (0 - 23)
+------------- min (0 - 59)
* in the value field above means all legal values as in braces for that column.
The value column can have a * or a list of elements separated by commas. An element is either a number in the ranges shown above or two numbers in the range separated by a hyphen (meaning an inclusive range).
Note: The specification of days can be made in two fields: month day and weekday. If both are specified in an entry, they are cumulative meaning both of the entries will get executed .
4. Crontab Example
_______
A line in crontab file like below removes the tmp files from /home/someuser/tmp each day at 6:30 PM.
30 18 * * * rm /home/someuser/tmp/*
Changing the parameter values as below will cause this command to run at different time schedule below :min hour day/month month day/week Execution time
30 0 1 1,6,12 * -- 00:30 Hrs on 1st of Jan, June & Dec.
:
0 20 * 10 1-5 --8.00 PM every weekday (Mon-Fri) only in Oct.
:
0 0 1,10,15 * * -- midnight on 1st ,10th & 15th of month
:
5,10 0 10 * 1 -- At 12.05,12.10 every Monday & on 10th of every month
:
Note : If you inadvertently enter the crontab command with no argument(s), do not attempt to get out with Control-d. This removes all entries in your crontab file. Instead, exit with Control-c.
5. Crontab Environment
___________
cron invokes the command from the user's HOME directory with the shell, (/usr/bin/sh).
cron supplies a default environment for every shell, defining:
HOME=user's-home-directory
LOGNAME=user's-login-id
PATH=/usr/bin:/usr/sbin:.
SHELL=/usr/bin/sh
Users who desire to have their .profile executed must explicitly do so in the crontab entry or in a script called by the entry.
6. Disable Email
____________
By default cron jobs sends a 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 .
>/dev/null 2>&1
7. Generate log file
________________
To collect the cron execution execution log in a file :
30 18 * * * rm /home/someuser/tmp/* > /home/someuser/cronlogs/clean_tmp_dir.log
8. Next Steps
This article covered a significant aspect of system administration of setting up cronjobs . Unix administration involves lots of different tasks and some of these tasks are covered in this website but still there are many areas not covered here .
Following books available for online buying from Amazon.com . You should have following two books in your bookshelf for ready reference if you are involved in Unix system administration .
Python2.5提供了标准的PEP 249 -- Python Database API Specification v2.0,可以使用基本一致的接口来访问各种类型的数据库,对应于ASE数据库,则有开源的python-sybase实现了该接口,从Web站点http://python-sybase.sourceforge.net上可以下载到该模块。
首先,确保系统中已经安装好了Python,并且也安装了Sybase ASE客户端,它带有OpenClient,从环境变量%SYBASE%以及%SYBASE_OCS%可以判断得到(linux/unix下是$SYBASE和$SYBASE_OCS)。
另外,由于安装过程需要对其中的C程序进行编译和链接,Windows平台需要拥有Microsoft Visual Studio .NET 2003\Vc7来进行编译。
从http://downloads.sourceforge.net/python-sybase/python-sybase-0.38.tar.gz下载到python-sybase的模块压缩包,将其解压至目录:python-sybase-0.38,发现其目录结构如下:
E:\LEARN\PYTHON\REF\PYTHON-SYBASE-0.38
├─build
│ ├─lib.win32-2.5
│ └─temp.win32-2.5
│ └─Release
├─doc
├─*.c, *.py, *.h 等
└─examples
一般情况下,直接运行python setup.py install,直接就完成了python-sybase模块的安装,实际情况,可能有些不太一样,从它的网站上的平台支持列表,我们可以看到,目前在Windows平台上,似乎不支持Openclient15.0.x。
表10-1 python-sybase支持平台及ASE版本
Client | Server | ||
OS | Libraries | OS | Libraries |
Linux | Sybase ASE 15.0.1 (32bits) | Linux | Sybase ASE 15.0.1 |
Linux 64-bits | OpenClient 12.5 | Linux | Sybase ASE 12.5 |
Linux | Sybase ASE 12.5 (32bits) | Linux | Sybase ASE 12.5 |
Linux | Sybase ASE 11.9.2 | Linux | Sybase ASE 11.9.2 |
Linux | Sybase ASE 11.0.3 | Linux | Sybase ASE 11.0.3 |
Linux | FreeTDS | Linux | Sybase ASA 9.0.2 |
Mac OS X 10.4.x | FreeTDS 0.62 | Linux | Sybase ASE 12.5 |
Windows 2000 Prof SP1 | Sybase ASE 11.9.2 | Windows NT 4.0 | Sybase ASE 11.9.2 |
Windows NT 4.0 SP6 | Sybase ASE 11.9.2 | HPUX 10.20 | Sybase ASE 11.9.2 |
Windows 98 | Sybase ASE 11.9.2 | NT 4.0 SP6 | OpenClient 11.5 |
Windows 95 OSR2 | Sybase ASE 11.9.2 | Solaris 2.6 | OpenClient 11.5 |
Solaris 10 | Sybase ASE 15.0.1 (32bits) | Solaris 10 | Sybase ASE 15.0.1 |
Solaris 10 | Sybase ASE 12.5 (32bits) | Solaris 10 | Sybase ASE 12.5 |
Solaris 8 | Sybase ASE 15.0.1 (32bits) | Solaris 8 | Sybase ASE 15.0.1 |
Solaris 8 | Sybase ASE 12.5 (32bits) | Solaris 8 | Sybase ASE 12.5 |
SunOS 5.9 | OpenClient 12.0 | SunOS 5.9 | Sybase ASE 12.5 |
Solaris 2.6 | Sybase ASE 11.5.1 | Solaris 8 | OpenClient 11.5 |
Solaris 5.6 | Sybase ASE 11.0.3 | | |
AIX 5.3 | Sybase ASE 15.0.1 (32bits) | AIX 5.3 | Sybase ASE 15.0.1 |
AIX 5.2 | Sybase ASE 12.5 (32bits) | AIX 5.2 | Sybase ASE 12.5.1 |
IRIX 6.5 | 11.5.1 | | |
HP-UX 11 | 11.5.1 | | |
要支持Sybase ASE15.0及以上版本,需要手动修改setup.py中的有关代码。
我们从中找到下面的代码块:
elif os.name == 'nt': # win32
# Not sure how the installation location is specified under NT
if sybase is None:
sybase = r'i:\sybase\sql11.5'
if not os.access(sybase, os.F_OK):
sys.stderr.write(
'Please define the Sybase installation directory in'
'the SYBASE environment variable.\n')
sys.exit(1)
syb_libs = ['libblk', 'libct', 'libcs']
将其中的syb_libs = ['libblk', 'libct', 'libcs']替换为syb_libs = ['libsybblk', 'libsybct', 'libsybcs']即可。原因是在ASE15.0及以上版本,这三个动态库的名字都发生了变化。我在Sybase ASE15.0下安装这个包时发现了此问题。15.0以下版本,无需修改该文件就可以安装。
安装的命令是:python setup.py install
安装完以后,在python目录下边,我们会发现有下述安装好的文件:
Lib\site-packages\Sybase.py
Lib\site-packages\python_sybase-0.38-py2.5.egg-info
Lib\site-packages\sybasect.pyd