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相同了!
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相同了!
相关文章推荐
- Linux下shell脚本在crontab中一个周期执行不完,下周期任务被重复执行的问题解决
- 使用 Shell 脚本自动化 Linux 系统维护任务
- RHCE 系列(四): 使用 Shell 脚本自动化 Linux 系统维护任务
- shell脚本定时任务 ( linux系统)
- shell脚本定时任务 ( linux系统)
- 使用 Shell 脚本自动化 Linux 系统维护任务
- 在linux中执行shell脚本,当前用户执行没有问题,设置为定时任务却报错
- linux直接执行shell脚本正常,使用定时任务crontab执行出错
- linux 下部署spring定时任务执行shell脚本,shell脚本执行spoon
- Linux 执行定时任务 shell脚本
- Linux 定时任务执行Shell脚本【CentOS6.8】
- 使用 Shell 脚本自动化 Linux 系统维护任务
- linux 定时执行shell脚本 定时任务
- Linux中执行shell脚本的4种方法总结
- 【转】linux 定时执行shell脚本
- PHP计划任务:如何使用Linux的Crontab执行PHP脚本(转)
- shell脚本实现每秒执行一次任务
- linux 定时执行shell脚本
- 使用Shell脚本对Linux系统和进程资源进行监控
- 让Linux下的cron以秒为单位执行shell脚本的3种方法