- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: New to UNIX, how do I create a scrip and a cro...
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
05-17-2005 04:07 AM
05-17-2005 04:07 AM
Any pointers?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2005 04:18 AM
05-17-2005 04:18 AM
Re: New to UNIX, how do I create a scrip and a cron job?
There are other issues to be aware of as well such as the type of environment you are in. You are making a blanket request and not all solutions will fit your needs.
As to cron;
00 21 * * *
00 05 * * *
This will execute dbshut at 2100 hrs daily
This will execute dbstart at 0500 hrs daily.
Again, this is a simple version of the syntax.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2005 04:20 AM
05-17-2005 04:20 AM
Re: New to UNIX, how do I create a scrip and a cron job?
I believe you already have a script...
Look in /sbin/init.d/ for something oracle related...
Does you oracle instance start at bootup?
If yes then at which runlevel - most chances to be 3, so look in /sbin/rc3.d/ a Sxxxoracle or something like
All this to say you have the script you now just need to create a cron file
man cron for a start
Then check with the sysadmin if you have the rights to create/use cron
All the best
Victor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2005 05:04 AM
05-17-2005 05:04 AM
Re: New to UNIX, how do I create a scrip and a cron job?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2005 05:14 AM
05-17-2005 05:14 AM
Re: New to UNIX, how do I create a scrip and a cron job?
who -r
To see how your script is launched, you should find in /sbin/rc2. a Kxxxfile linked to your oracle file in /sbin/init.d the same goes for rc3.d but this time you have to look for a Sxxxfile.
All the best
Victor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2005 05:59 AM
05-17-2005 05:59 AM
Re: New to UNIX, how do I create a scrip and a cron job?
How this works? Do I have to create the file in /sbin/init.d and link it to /sbin/rc2.d?
I'm kind of lost here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2005 10:35 AM
05-17-2005 10:35 AM
Re: New to UNIX, how do I create a scrip and a cron job?
the rc.2 directory means that when the system is booted oracle starts at run level 2, the system is up at run level 3 (/sbin/rc.3/) and a whole bunch of other programs / process will be started at this level as the server is booted.
You want to stop and start oracle via cron, once you find the options from the oracle script add the following to cron:
00 21 * * * /sbin/init.d/oracle stop
00 05 * * * /sbin/init.d/oracle start.
This should do the trick.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2005 05:33 PM
05-17-2005 05:33 PM
Re: New to UNIX, how do I create a scrip and a cron job?
root
oracle
:wq!#then save and exit
2, get attached file for scripts
3, su - oracle
[server:/] su - oracle
exit crontab
#crontab -e
[server:/home/oracle] crontab -e
# minute hour date month weekday command
00 21 * * * sh /home/oracle/scripts/Ora_shutdown.sh
00 05 * * * sh /home/oracle/scripts/Ora_start.sh
that's all
tienna
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2005 09:31 PM
05-17-2005 09:31 PM
Solution>On /sbin/rc2.d I found S910oracle linked to oracle in
>/sbin/init.d but on /sbin/rc3.d was nothing that I could relate to Oracle.
>
>How this works? Do I have to create the file in
>/sbin/init.d and link it to /sbin/rc2.d?
at run level 2 when the system is booting it looks sequentialy for files to start and
called S0XXXfile and gives the start option
at level 1 when system i beeing brought down
It look for Kxxxfile and give stop argument
I believe your oracle file should be in rc2.d for Kxxx and rc3 for SYYY
But its up to you...
Here is an example of what we do for start/stop scripts for oracle:
#!/usr/bin/ksh
export ORACTI_EXPLOIT=/opt/oracle/admin/exploit
export PATH=$PATH:/usr/bin:$ORACTI_EXPLOIT/proc
case "$1" in
start_msg)
echo "Start Oracle"
;;
stop_msg)
echo "Stop Oracle"
;;
start)
$ORACTI_EXPLOIT/proc/db_start
su - oracle -c $ORACTI_EXPLOIT/proc/net_start
;;
stop)
su - oracle -c $ORACTI_EXPLOIT/proc/net_stop
$ORACTI_EXPLOIT/proc/db_shut
;;
*)
echo "usage: $0 {start|stop}"
#rval=1
;;
esac
----------------------------------------
Here is an extract of a cronfile the way I do...
Notice I put conrfiles in a structure /sm/cron with big comments on the syntax
and usage since I have poor memory...
This leaves a way to modify the the cronfile by getting it at its location.
TO load it is simply crontab cronfile.root
--------------------------------------
# /sm/cron/cronfile.root
# crontab file for the super-user.
#
# ==========================================================================
# F O R M A T
# ==========================================================================
# Minute Hour Month_Day Month Weekday Command
# (0-59) (0-23) (1-31) (1-12) (0-6)*0=sun run-string
# * = in any crontab field represents all legal values.
# Therefore, to schedule the ps(1) cmd to execute at 5:10pm on every
# friday and monday during june, july, august, you would make an entry
# in your crontab fithe that looks like this :
# 10 17 * 6,7,8 1,5 ps>>psfile 2>&1
# The 2>&1 redirects any error msg to the file psfile.
# ==========================================================================
# archive annuelle de l export le 3 dimanche de janvier chaque annee
#00 04 * 1 0 /sm/bin/archive_annuelle >>/sm/log/archive_ann.er 2>&1
# log kernel diagnostic messages every 10 minutes
05,15,25,35,45,55 * * * * /usr/sbin/dmesg - >>/var/adm/messages
#05,15,20,35,45,55 * * * * /usr/bin/ulimit >>/var/adm/ulimit.cron 2>&1
#05,15,21,35,45,55 * * * * /usr/bin/ulimit -a >>/var/adm/ulimit.cron 2>&1
07,17,27,37,47,57 * * * * /var/adm/root/clean_tmp>>/var/adm/cleantmp.log 2>&1
# Sample nightly invocation of calendar. If you wish to run calendar,
# just uncomment the next line.
#0 4 * * * exec /usr/bin/calendar -
# ==========================================================================
# effacer les disques temporaires
# ==========================================================================
#
00 23 * * 1,2,3,4,5 /sm/cron/bin/effacer>>/sm/cron/log/efface.log 2>&1
05 23 * * 1,2,3,4,5 /sm/cron/bin/clean_xprt_s>/sm/cron/log/cleanXs.log 2>&1
# ============================ E N D =======================================
NOw user who are allowed to use cron or at cmd ar defined in files in /var/adm/cron:
-r--r--r-- 1 bin bin 18 Nov 14 2000 at.allow
-r--r--r-- 1 bin bin 31 Feb 12 2003 cron.allow
-rw-r--r-- 1 root root 1041016 May 18 10:47 log
in cron .allow and at.allow you give the users you are allowed:
:/var/adm/cron $ more cron.allow
root
adm
vbe
uucp
prod
rdm
dupont
-----
Courage!!
All the best
Victor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2005 02:08 AM
05-18-2005 02:08 AM
Re: New to UNIX, how do I create a scrip and a cron job?
As far as oracle startup script exists in /sbin/init.d and is linked to /sbin/rc2.d.. it should suffice.
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2005 12:40 AM
05-24-2005 12:40 AM
Re: New to UNIX, how do I create a scrip and a cron job?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2005 12:46 AM
05-24-2005 12:46 AM
Re: New to UNIX, how do I create a scrip and a cron job?
[server:/] su - oracle
exit crontab
#crontab -e
I got this:
kcspecdp prdcop >exit crontab
ksh: crontab: bad number
logout
After entering this kcspecdp # crontab -e VI gets started.
What I'm doing wrong?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2005 12:59 AM
05-24-2005 12:59 AM
Re: New to UNIX, how do I create a scrip and a cron job?
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2005 01:09 AM
05-24-2005 01:09 AM
Re: New to UNIX, how do I create a scrip and a cron job?
su - oracle -c $ORACLE_BIN/dbshut
# This is an oracle provided script to stop database(s)
# verify the database is down by checking procs
# example, ps -ef | grep -e pmon -e smon
# do the backup
su - oracle -c $ORACLE_BIN/dbstart
# This is an oracle provided script to start database(s)
# verify database is up by checking procs
# example, ps -ef | grep -e pmon -e smon
Depending on your backup application, there is usually some sort of pre- and post-exec procedure that you can configure so that the oracle stop/start script is run in conjuction with the backup itself. All that is needed in the cron is a job that fires off the backup.
00 21 * * * /$HOME/bin/do_backup
You do your backup at 2100 hrs daily, 7 days a week. The script is called 'do_backup' and has all the stuff in it. This can eliminate the need to have 2 cronjobs and can reduce the downtime of the oracle database(s) by starting the databases as soon as the backup is completed.
Beware, depending on the version of oracle you are using, there were some troubles with the dbshut/dbstart scripts as supplied. The fix was simple but just so you have the knowledge of.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2005 01:29 AM
05-24-2005 01:29 AM
Re: New to UNIX, how do I create a scrip and a cron job?
Is there a way to verify if the scripts were executed?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2005 01:43 AM
05-24-2005 01:43 AM
Re: New to UNIX, how do I create a scrip and a cron job?
The backup will be done thru a Windows box running Networker. It has the ability to execute pre and post job commands but don't know if that only works on the Windows side, I'll give that a try to see if it works.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2005 01:44 AM
05-24-2005 01:44 AM
Re: New to UNIX, how do I create a scrip and a cron job?
Example; LOG=$HOME/my_backup_log
In your script have the command outputs redirected to $LOG.
some_command >> $LOG
Can add a `date` feature in there as well to help you keep track
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2005 01:45 AM
05-24-2005 01:45 AM
Re: New to UNIX, how do I create a scrip and a cron job?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2005 12:38 AM
05-25-2005 12:38 AM
Re: New to UNIX, how do I create a scrip and a cron job?
! *** cron started *** pid = 1098 Fri May 20 07:15:58 SAT 2005
> CMD: sh /u01/dba/oracle/scripts/Ora_shutdown.sh
> oracle 13042 c Tue May 24 23:00:01 SAT 2005
< oracle 13042 c Tue May 24 23:00:01 SAT 2005 rc=1
> CMD: sh /u01/dba/oracle/scripts/Ora_start.sh
> oracle 13300 c Wed May 25 05:00:01 SAT 2005
< oracle 13300 c Wed May 25 05:00:01 SAT 2005 rc=1
Did the cron job worked?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2005 02:00 AM
05-25-2005 02:00 AM
Re: New to UNIX, how do I create a scrip and a cron job?
http://www4.itrc.hp.com/service/james/search.do?rn=25&source=7000&searchcategory=ALL&from=forums&hpl=1&todo=search&origin=0&wpa=forums1.itrc.hp.com%3A80&searchcriteria=allwords&esc=europe-support3.external.hp.com&searchtext=rc+error&chkServStor=on&presort=rank
Good luck,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2005 02:00 AM
05-25-2005 02:00 AM
Re: New to UNIX, how do I create a scrip and a cron job?
A cronjob fired off by oracle at 2300 hrs on May 24 with PID of 13042 but for some reason got a error of rc=1.
> CMD: sh /u01/dba/oracle/scripts/Ora_shutdown.sh
oracle 13042 c Tue May 24 23:00:01 SAT 2005
oracle 13042 c Tue May 24 23:00:01 SAT 2005 rc=1
A cronjon fired off by oracle at 0500 hrs on May 25 with PID of 13300 but again got rc=1.
> CMD: sh /u01/dba/oracle/scripts/Ora_start.sh
> oracle 13300 c Wed May 25 05:00:01 SAT 2005
< oracle 13300 c Wed May 25 05:00:01 SAT 2005 rc=1
A couple of places to check. Look at the alert.log for oracle. From the $ORACLE_HOME you should be able to do a 'find . -name alert.log -print' command to find the alert log. (This can be put elsewhere so check with DBAs). View the alert log, if the database went down and started up again then these entries will be in alert log.
Another thought is that when you put jobs into cron for execution you must set all the environment variables. The cron does not carry over any of these env settings.
In your scripts put in the 'set -xv'. If you can run manually try it. Else let the next cron job run it and see what the output says.
For your cronjob, have it send output to your email.
Example:
00 23 * * * /u01/dba/oracle/scripts/Ora_shutdown.sh | mailx -s "My oracle stop cron" you@address.com
00 05 * * * /u01/dba/oracle/scripts/Ora_start.sh | mailx -s "My oracle start cron" you@address.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2005 02:20 AM
05-25-2005 02:20 AM
Re: New to UNIX, how do I create a scrip and a cron job?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2005 02:30 AM
05-25-2005 02:30 AM
Re: New to UNIX, how do I create a scrip and a cron job?
As far as Networker - not too sure if you can get it to execute a script on the Unix server or not - I would think you could....
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2005 02:33 AM
05-25-2005 02:33 AM