- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: how to configure cron
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2011 04:52 AM
02-22-2011 04:52 AM
Re: how to configure cron
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2011 05:00 AM
02-22-2011 05:00 AM
Re: how to configure cron
You keep the space omission between "sh -x" and "/u02/scripts/rename.sh".
2_17_*_*_*_/usr/bin/sh_-x_/u02/scripts/rename.sh_>>_/tmp/rename.log_2>&1
_ means space between words.
Rgds.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2011 05:15 AM
02-22-2011 05:15 AM
Re: how to configure cron
>less rename.sh
>/usr/bin/mv /u02/scripts/my_file.log /u03/export/my_file_$(/usr/bin/date +%m%d%Y).log
You really should start your script with:
#!/usr/bin/sh
Have you tested a dynamic variable for the date?
V.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2011 11:01 AM
02-22-2011 11:01 AM
Re: how to configure cron
Right. When you use cron, you start in your home directory. Where are you when you invoke the script manually?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2011 02:21 AM
02-23-2011 02:21 AM
Re: how to configure cron
$crontab -l
35 9 * * * /usr/bin/sh -x /u02/dump/rename.sh >> /tmp/crontasks.log 2>&1
$less rename.sh
/usr/bin/mv /u02/dump/my_file.log /u02/dump/my_file_$(/usr/bin/date +%m%d%Y).log
I wanted to run some other scripts through cron.
I have script which makes dump files of database. I run it manually when we need.
$less exportSID.sh
expdp system/password@SID FULL=y DUMPFILE=my_file%U.dmp DIRECTORY=my_dir FILESIZE=4G LOGFILE=my_file.log JOB_NAME=FULLexp
Then I add task in cron
45 12 * * * /usr/bin/sh -x /u02/dump/exportSID.sh >> /tmp/crontasks.log 2>&1
Got error in /tmp/crontasks.log:
+ expdp system/password@SID FULL=y DUMPFILE=my_file%U.dmp DIRECTORY=my_dir FILESIZE=4G LOGFILE=my_file.log JOB_NAME=FULLexp
/u02/dump/exportSID.sh: expdp: not found.
Then I changed my script
/u01/app/oracle/product/10.2.0/db_1/bin/expdp system/password@SID FULL=y DUMPFILE=my_file%U.dmp DIRECTORY=my_dir FILESIZE=4G LOGFILE=my_file.log JOB_NAME=FULLexp
Got this error:
+ /u01/app/oracle/product/10.2.0/db_1/bin/expdp system/password@SID FULL=y DUMPFILE=my_file%U.dmp DIRECTORY=my_dir FILESIZE=4G LOGFILE=my_file.log JOB_NAME=FULLexp
UDE-00013: Message 13 not found; No message file for product=RDBMS, facility=UDE
UDE-00019: You may need to set ORACLE_HOME to your Oracle software directory
Showed my ORACLE_HOME in export script:
$ORACLE_HOME/bin/expdp system/password@SID FULL=y DUMPFILE=my_file%U.dmp DIRECTORY=my_dir FILESIZE=4G LOGFILE=my_file.log JOB_NAME=FULLexp
Got error:
+ /bin/expdp system/password@SID FULL=y DUMPFILE=my_file%U.dmp DIRECTORY=my_dir FILESIZE=4G LOGFILE=my_file.log JOB_NAME=FULLexp
/u02/dump/exportSID.sh: /bin/expdp: not found.
Tried another method in script:
Showed my ORACLE_HOME in export script
/ORACLE_HOME/bin/expdp system/password@SID FULL=y DUMPFILE=my_file%U.dmp DIRECTORY=my_dir FILESIZE=4G LOGFILE=my_file.log JOB_NAME=FULLexp
Got error:
+ /ORACLE_HOME/bin/expdp system/password@SID FULL=y DUMPFILE=my_file%U.dmp DIRECTORY=my_dir FILESIZE=4G LOGFILE=my_file.log JOB_NAME=FULLexp
/u02/dump/exportSID.sh: /ORACLE_HOME/bin/expdp: not found.
So how I can show expdp in correct syntax?
#whence mv
gave me /usr/bin
but #whence expdp didnâ t give me path.
So I think expdp must be run from ORACLE_HOME/bin
regards,
rustam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2011 04:09 AM
02-23-2011 04:09 AM
Re: how to configure cron
Congratulations, hard to solve!
The command "whence" only reports about "something" when that "something" is reachable through the global variable PATH, and also has execute permissions.
Best regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2011 05:47 AM
02-23-2011 05:47 AM
Re: how to configure cron
You can now remove the /usr/bin path for mv and date.
>I think expdp must be run from ORACLE_HOME/bin
Yes. And you must export ORACLE_HOME since your ~/.profile isn't executed by cron.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2011 12:06 AM
02-24-2011 12:06 AM
Re: how to configure cron
a cron job doesn´t know *your* path variables. You have to define it at the beginning of the script.
I think ORACLE_HOME is not the only variable you have defined in your profile for your database.
Check for all maybe needed variables in your .profile and define it at the beginning of your cron script.
Then you can use it also in your script ($ORACLE_HOME/bin/expdp).
You can also use full path of your command.
It's up to you.
HTH
V.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2011 02:25 AM
02-24-2011 02:25 AM
Re: how to configure cron
Jose, for global PATH do i need add path in /home/my_user/.profile or in root's directory?
I have ORACLE_HOME and other path's in /home/my_user/.bash_profile and $echo $ORACLE_HOME returns me
$/u01/app/oracle/product/10.2.0/db_1 but i log in by root and got error: sh: ORACLE_HOME: Parameter not set.
Yeah Dennis, thanks. Now mv and date work without full path. Last night rename script run correctly.
>>Yes. And you must export ORACLE_HOME since your ~/.profile isn't executed by cron.
should i add under root or my_user catalog /home/user_name/ ?
V,
can i add in my script these values?
export NLS_LANG=AMERICAN_CIS.AL32UTF8
export ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1
$ORACLE_HOME/bin/expdp system/password@SID FULL=y DUMPFILE=my_file%U.dmp DIRECTORY=my_dir FILESIZE=4G LOGFILE=my_file.log JOB_NAME=FULLexp
>>You can also use full path of your command.
I did this trip and got error. I wrote about it on my previous post.
Regards,
rustam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2011 02:44 AM
02-24-2011 02:44 AM
Re: how to configure cron
You can have the real shell give errors if you try to use an uninitialized variable:
set -u
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2011 03:00 AM
02-24-2011 03:00 AM
Re: how to configure cron
>should i add under root or my_user catalog /home/user_name/ ?
No - the problem is that cron will NOT read any user profile settings, so you have to define it in the cron script.
>>You can also use full path of your command.
>I did this trip and got error. I wrote about it on my previous post.
Yes, you got errors, but the script was executed - but it seems like the script itself needs more variables like ORACLE_HOME!
(-> error code UDE-00019)
So yes, try the cron job with the added export lines.
Hopefully the other error (UDE-00013) doesn't appear, else you need more investigation and search for a text file which translates this UDE-00013 error.
Or ask the hotline of this application, they should know it.
HTH
V.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2011 01:49 AM
02-25-2011 01:49 AM
Re: how to configure cron
I could run my script for taking dump of database via cron. I use these configurations:
$crontab -l
14 13 * * * /usr/bin/sh -x /u02/dump/exportSID.sh >> /tmp/crontasks.log 2>&1
$less export SID.sh
export NLS_LANG=AMERICAN_CIS.AL32UTF8
export ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1
$ORACLE_HOME/bin/expdp system/pass@SID ..
regards and thanks a lot,
rustam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2011 02:55 AM
02-25-2011 02:55 AM
Re: how to configure cron
are there any option of cron which stops for few days\weeks\months some tasks?
or all i need is run crontab -e and delete needed line(task)?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2011 03:04 AM
02-25-2011 03:04 AM
Re: how to configure cron
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)
By other hand if you comment (# character) the crontab line (crontab -e) the task will not executes.
Rgds.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2011 03:18 AM
03-03-2011 03:18 AM
Re: how to configure cron
Dump files generate with sysdate and then log file renames to sysdate via cron tasks. Everything is ok.
But there is one task which i do manually everyday. Dump file(s) size are ~35Gb and i need to compress them and put ziped dump file and log file in one archive, coz have limited space in my disk arrays.
I run command everyday:
$ zip my_filename
$ tar cvf myfile_$(date +%m%d%Y).tar myfile_
Is it possible in my situation do script and then run via cron job which uses variable file name (sysdate parameter is changed everyday)
regards,
rustam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2011 04:39 AM
03-03-2011 04:39 AM
Re: how to configure cron
If there is real guarantee that the
#gzip -9 my_filename_$(date +%m%d%Y).dmp
#tar cf my_filename_$(date +%m%d%Y).tar my_filename_$(date +%m%d%Y)*.[gl]*
By the way, how is generated the dump file (. dmp)? It is generated from a previous command (ie: a database export using the command "exp")?
I mention this because we see the possibility to compress the file while being generated (On the fly).
Rgds.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2011 12:50 AM
03-04-2011 12:50 AM
Re: how to configure cron
I think it's what i needed:
#gzip -9 my_filename_$(date +%m%d%Y).dmp
#tar cf my_filename_$(date +%m%d%Y).tar my_filename_$(date +%m%d%Y)*.[gl]*
i checked several times manually. it works fine.
You used tar with option cf. Before i used cvf so it's not problem i will not use v? as official document says - this parameter gives information about archived files.
>>By the way, how is generated the dump file (. dmp)? It is generated from a previous >>command (ie: a database export using the command "exp")?
>>I mention this because we see the possibility to compress the file while being >>generated (On the fly).
Yeah, dump file(s) generates from expdp utility which i mentioned before:
expdp system/password@SID FULL=y DUMPFILE=my_file_$(date +%m%d%Y).dmp DIRECTORY=my_dir LOGFILE=my_file.log
so what does mean - on the fly? Do you mean that i can compress my dump file(s) while it is generated? i think i need to read expdp syntax.
regards,
rustam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2011 02:09 AM
03-04-2011 02:09 AM
Re: how to configure cron
The -v option is the verbose option, just create an execution output for your default output file, in this case your display.
Compress a file at the time of generation is not an option of the DB Utility. The trick is to use a file "pipe" to make a bridge between the dump's output and gzip's input. This is a compression "On the Fly".
As a major benefit is the saving of disk space. The impact on the processing time will depend more of CPU power and RAM available.
Please see the attachment example
Remember, this is guide, you must adapt to your work environment. :)
Rgds.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2011 11:54 PM
03-06-2011 11:54 PM
Re: how to configure cron
Ok, i got that i may not use -v option. Also i understood the 'on the fly' concept.
Should i create pipe file where is my script or it doesnt matter(path)? I attached edit version of your script. would you check it? so in this case i dont need to use rename script, right? i mean if i run script via cron then all tasks must be done? generation dump file, rename log file, gzip all files with sysdate and archive them.
regards,
rustam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2011 01:27 AM
03-07-2011 01:27 AM
Re: how to configure cron
>>Should I create pipe file where is my script or it doesnt matter (path)?
As you see, the size of pipe file is minimal and never change, is just a pipe. You must place it as your order convenience, I suggest you place it into same dump file generation path to avoid possible permission issues among involved directories. Also I suggest you that uses a pipe name related with your SID to avoid any possible concurrent use in future (i.e: ${SID}exp_pipe)
>>I mean if I run script via cron then all tasks must be done?
As you see the script done an export/compress of the data at a specific timestamp, using this timestamp as part of name of related files (compressed and log files).
By other hand, I guess that this script file will be run by oracle's user. Then must ensure that directories and file permission will be adecuated, also configure this task in the oracle's user cron.
Rgds.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2011 02:37 AM
03-07-2011 02:37 AM
Re: how to configure cron
>>By other hand, I guess that this script >>file will be run by oracle's user. Then >>must ensure that directories and file >>permission will be adecuated, also >>configure this task in the oracle's user >>cron.
yeah, oracle user must run this script. I will configure cron as OS oracle user.
I made last version of your script(in attached). Is it ok?
>># so it is not appropriate to delete the files that should be contained inside it.
>># When this script have been tested and works fine, uncomment the following comment >>lines:
>>#if [ "$?" = "0" ]
>>#then
>># rm /u02/dump/$DUMPFILE.dmp.gz =/u02/dump/$LOGFILE.log
So if i will uncomment rm /u02/dump/$DUMPFILE.dmp.gz =/u02/dump/$LOGFILE.log then all files(which have been created on sysdate) after archiving will delete, right? i think it's great.
regards,
Rustam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2011 02:46 AM
03-07-2011 02:46 AM
Re: how to configure cron
If you want to check the exit status you should do a numeric compare:
if [ $? -eq 0 ]; then
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2011 03:21 AM
03-07-2011 03:21 AM
Re: how to configure cron
On second thought, is not very wise to encapsulate the files (. gz and. log) within a file. tar. You need longer run time and at some time need enough disk space to accommodate .gz (usually large) and the .tar files. In my opinion a waste of resources. Do not worry about maintaining two types of files (.gz and .log) in /u02/dump.
Your last attached file was not the latest version. I now include a final version reflects the latest tips.
By the way, this question has become so large that it is difficult to follow, when you consider appropriate should start a new one. :)
Rgds.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2011 03:42 AM
03-07-2011 03:42 AM
Re: how to configure cron
By habit I always use symbols (=, != ,> ,<) and not operators (-eq, -ne, -gt, -lt) for comparison within an "if. " It is a personal habit, good or bad. For this reason you also notices that the compared variables are forced to be interpreted as alphanumeric enclosing them within double quotes. The right thing is to do it as you say. Thank you for your comment.
Rgds
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2011 08:15 PM
03-08-2011 08:15 PM
Re: how to configure cron
I tested final version and got error like this.
$./370653.sh
./370653.sh[12]: mknod: not found.
./370653.sh[15]: /u02/dump/my_sidexp_pipe: Cannot find or open the file.
LRM-00101: unknown parameter name 'file'
rm: /u02/dump/my_sidexp_pipe non-existent
seems couldnt create pipe file?
Maybe better i should use on fly compress? how much it will be faster? for instance, taking dump takes 1.2 h and making compress 40min.
Regards,
Rustam