Wikipedia

Search results

what does "2>&1" do in crontab?

What does "2>&1" do in crontab?


Example:
01 * * * * /oracle/work/ak/test.sh >/oracle/work/ak/logtest.out  2>&1

The command 2>&1 is to prevent crontab sending an email (sendmail on /var/mail/root) when the script fails. so, if the error occurs when the crontab script fails, then the email will dump to logtest.out not on /var/mail/root.

here we go,
The 2>&1 just redirects Channel 2 (Standard Error) and Channel 1 (Standard Output) to the same place which in this context is Channel 1 (Standard Output), and thence your log file.
If all output from a cron is redirected to a file, it will not generate an email of the output to Stdout or Stderr.

Hope this helps ;-)

CONTROL_FILE_RECORD_KEEP_TIME parameter

CONTROL_FILE_RECORD_KEEP_TIME parameter

scenario : RMAN - Not able to retained the backup more than 20 days, But configured as 45 days. 

Oracle says :


RMAN backup keeps the backup metadata information in the reusable section of the controlfile. Its depends on the parameter CONTROL_FILE_RECORD_KEEP_TIME. CONTROL_FILE_RECORD_KEEP_TIME specifies the minimum number of days before a reusable record in the control file can be reused. 

In the event a new record needs to be added to a reusable section and there is not enough space then it will delete the oldest record, which are aged enough.

Backup retention policy is the rule to set regarding which backups must be retained (whether on disk or other backup media) to meet the recovery and other requirements.

If the CONTROL_FILE_RECORD_KEEP_TIME is less than the retention policy then it may overwrite reusable records prior to obsoleting them in the RMAN metadata. Therfor it is recommended that the CONTROL_FILE_RECORD_KEEP_TIME should set to a higher value than the retention policy.

Formula

CONTROL_FILE_RECORD_KEEP_TIME = retention period + level 0 backup interval + 1

For e.g.

e.q. level 0 backup once a week with retention policy of a recovery windows of 45 days then in this 
case the CONTROL_FILE_RECORD_KEEP_TIME should be 45+7+1=53

SQL> SHOW PARAMETER KEEP TIME;

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
control_file_record_keep_time        integer     7

SQL> ALTER SYSTEM SET CONTROL_FILE_RECORD_KEEP_TIME=53 SCOPE=BOTH;

** Now you can able to retain the backup .

Moving/Renaming Datafiles While the Database is Online

It is possible to move and or rename datafiles while the database is online provided the tablespace in which the files belong is a non SYSTEM tablespace and does not contain any active ROLLBACK or TEMPORARY segments.
This document will detail the steps to move/rename a datafile using Oracle 11g R2 on Linux. These steps also apply with 10g.
The datafile for the TEST tablespace is in the wrong directory. The file should be in /u02/app/oracle/oradata/orcl.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
SQL> select file_name from dba_data_files;
 
FILE_NAME
--------------------------------------------------------------------------------
/u02/app/oracle/oradata/orcl/users01.dbf
/u02/app/oracle/oradata/orcl/undotbs01.dbf
/u02/app/oracle/oradata/orcl/sysaux01.dbf
/u02/app/oracle/oradata/orcl/system01.dbf
/u02/app/oracle/oradata/orcl/example01.dbf
/u02/app/oracle/oradata/test/test.dbf
 
6 rows selected.
 
SQL>
The first step is to take the tablespace in which the file(s) to moved/renamed are a member offline.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[oracle@ora1 ~]$ sqlplus / as sysdba
 
SQL*Plus: Release 11.2.0.1.0 Production on Mon Apr 12 09:28:58 2010
 
Copyright (c) 1982, 2009, Oracle.  All rights reserved.
 
 
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
 
SQL> alter tablespace test offline;
 
Tablespace altered.
 
SQL>
Next we move the file using operating system commands.
1
2
3
4
5
6
SQL> host
[oracle@ora1 ~]$ mv /u02/app/oracle/oradata/test/test.dbf /u02/app/oracle/oradata/orcl/test.dbf
[oracle@ora1 ~]$ exit
exit
 
SQL>
Now we need to update the data dictionary and the control. We will use the ALTER DATABASE RENAME FILE statement to perform those actions.
1
2
3
4
5
SQL> alter database rename file '/u02/app/oracle/oradata/test/test.dbf' to '/u02/app/oracle/oradata/orcl/test.dbf';
 
Database altered.
 
SQL>
Last thing to do is bring the tablespace back online.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
SQL> alter tablespace test online;
 
Tablespace altered.
 
SQL> select file_name from dba_data_files;
 
FILE_NAME
--------------------------------------------------------------------------------
/u02/app/oracle/oradata/orcl/users01.dbf
/u02/app/oracle/oradata/orcl/undotbs01.dbf
/u02/app/oracle/oradata/orcl/sysaux01.dbf
/u02/app/oracle/oradata/orcl/system01.dbf
/u02/app/oracle/oradata/orcl/example01.dbf
/u02/app/oracle/oradata/orcl/test.dbf
 
6 rows selected.
 
SQL>
The move/rename is complete.