这篇文章将为大家详细讲解有关怎么理解定时任务crontab,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。
让客户满意是我们工作的目标,不断超越客户的期望值来自于我们对这个行业的热爱。我们立志把好的技术通过有效、简单的方式提供给客户,将通过不懈努力成为客户在信息化领域值得信任、有价值的长期合作伙伴,公司提供的服务项目有:主机域名、虚拟空间、营销软件、网站建设、广东网站维护、网站推广。脚本目录:
[oracle@tangjian ~]$ mkdir -p /u01/app/oracle/rman/scripts/
归档目录:
[oracle@tangjian ~]$ mkdir -p /u01/app/oracle/rman/arch/
创建脚本:(每月一次0级增量)
[oracle@tangjian ~]$ vi /u01/app/oracle/rman/scripts/full_backup_run.sh
#!/bin/bash
#Usage:test database hot full backup !
export PATH
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export ORACLE_SID=test
export PATH=$PATH:$ORACLE_HOME/bin
DATE=$(date +%Y%m%d)
mkdir -p /u01/app/oracle/rman/$DATE
rman target / < run{ allocate channel c1 type disk; allocate channel c2 type disk; sql'alter system switch logfile'; crosscheck archivelog all; delete noprompt expired archivelog all; backup incremental level 0 database format '/u01/app/oracle/rman/$DATE/test_%U.bk' include current controlfile plus archivelog delete input format '/u01/app/oracle/rman/arch/arch_test_%U.arch'; crosscheck archivelog all; delete noprompt obsolete; delete noprompt backup of database completed before 'sysdate - 32'; release channel c1; release channel c2; } exit; EOF [root@tangjian ~]# chmod -R 775 /u01/app/oracle/rman/scripts/full_backup_run.sh 添加定时任务: [oracle@tangjian 20180730]$ crontab -e #rman backup full database shell 52 14 * * * /u01/app/oracle/rman/scripts/full_backup_run.sh 1>/u01/app/oracle/rman/rman_backup_full.log 2>&1 查看任务列表: [oracle@tangjian 20180730]$ crontab -l 创建脚本:(每星期一次1级差异增量) [oracle@tangjian ~]$ vi /u01/app/oracle/rman/scripts/level_backup_run.sh #!/bin/bash #Usage:test database hot full backup ! export PATH export ORACLE_BASE=/u01/app/oracle export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1 export ORACLE_SID=test export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin DATE=$(date +%Y%m%d) mkdir -p /u01/app/oracle/rman/level/$DATE rman target / < run{ allocate channel a1 device type disk; allocate channel a2 device type disk; sql'alter system switch logfile'; crosscheck archivelog all; delete noprompt expired archivelog all; backup incremental level 1 database format '/u01/app/oracle/rman/level/$DATE/test_%U.bk' include current controlfile plus archivelog delete input format '/u01/app/oracle/rman/arch/arch_test_%U.arch'; crosscheck archivelog all; delete noprompt obsolete; delete noprompt backup of database completed before 'sysdate -32'; release channel a1; release channel a2; } exit; EOF [root@tangjian ~]# chmod -R 775 /u01/app/oracle/rman/scripts/level_backup_run.sh 添加定时任务: [oracle@tangjian 20180730]$ crontab -e #rman backup full database shell 00 1 1 * * /u01/app/oracle/rman/scripts/full_backup_run.sh 1>/tmp/rman_backup_full.log 2>&1 #rman backup level database shell 00 1 * * 7 /u01/app/oracle/rman/scripts/level_backup_run.sh 1>/tmp/rman_backup_full.log 2>&1 验证脚本可用性: [oracle@tangjian scripts]$ sh full_backup_run.sh [oracle@tangjian scripts]$ sh level_backup_run.sh 常用命令: /sbin/service crond stop 关闭服务 /sbin/service crond restart 重启服务 /sbin/service crond reload 重新载入配置 在/etc/rc.d/rc.local这个脚本的末尾加上(开机自启): /sbin/service crond start crontab -u
设定某个用户的cron服务,一般root用户在执行这个命令的时候需要此参数 crontab -l
列出某个用户cron服务的详细内容 crontab -r 删除某个用户的cron服务 crontab -e
编辑某个用户的cron服务 关于怎么理解定时任务crontab就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。
/sbin/service crond start 启动服务
新闻名称:怎么理解定时任务crontab-创新互联
分享路径:http://lswzjz.com/article/ddgjgp.html