您的位置:首页 > 运维架构 > Shell

solaris\linux下建系统任务执行shell脚本

2013-02-18 11:05 351 查看
linux系统下:

1、建存放脚本的目录,如:

[oracle@localhost]$mkdir /home/oracle/bin

2、修改系统环境变量文件中的PATH变量,加上/home/oracle/bin目录

[oracle@localhost]$vi .bash_profile

# .bash_profile

# Get the aliases and functions

if [ -f ~/.bashrc ]; then

        . ~/.bashrc

fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin:/home/oracle/bin

export PATH

unset USERNAME

------

应用环境变量:

[oracle@localhost]source .bash_profile

也可直接用export定义变量:

[oracle@localhost]$export PATH=$PATH:/home/oracle/bin

3、在/home/oracle/bin目录创建shell脚本exp_user.sh

[oracle@localhost]$ cat > exp_user.sh

exp system/oracle owner=user1 file=/oradata/user1.dmp

Ctrl+C

4、给脚本赋执行权限:

[oracle@localhost]$chmod u+x exp_user.sh

5、创建执行作业计划脚本:

[oracle@localhost]$cat > cronfile

0 1 * * * /home/oracle/bin/exp_user.sh

6、提交作业:

[oracle@localhost]$crontab cronfile

[oracle@localhost]$crontab -l

0 1 * * * /home/oracle/bin/exp_user.sh

solaris系统下:

1、与linux相同

2、开始的修改vi .profile(注意solaris环境变量文件名是.profile,用ls -a命令可以看隐藏文件)是相同的,但是不能用source .profile命令应用文件中变量,要执行下面的操作:

注意:Solaris的sh不支持export PATH=$PATH:/home/oracle/bin这样的写法配置环境变量,需要改为两行:

[oracle@localhost]$PATH=$PATH:/home/oracle/bin

[oracle@localhost]$export PATH

下面的步骤3、4、5、6就跟linux相同了!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: