- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Crontab in korn shell?
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
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
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
тАО12-30-2004 05:24 PM
тАО12-30-2004 05:24 PM
Crontab in korn shell?
just to confirm I have add my job as follow:
"5 * * * * /users/tester/BACKUP_LOG/main.sh" for it to run at every 5 mins, is this correct?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-30-2004 05:40 PM
тАО12-30-2004 05:40 PM
Re: Crontab in korn shell?
cron itself runs with the default Posix shell but you can run your programs through any shell:
either specify it with the instruction:
5 * * * * ksh program.ksh
or specify it in the shell script itself:
#! /bin/ksh
# "#!" as first characters in script will define the interpreter.
regards,
Thierry Poels.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-30-2004 05:43 PM
тАО12-30-2004 05:43 PM
Re: Crontab in korn shell?
5 * * * *
will run the job 5 minutes past every hour: 00:05, 01:05, 02:05, .... 23,05
To run it every 5 minutes you'll need to specify the "minutes":
0,5,10,15,20,25,30,35,40,45,50,55 * * * *
(sorry no easier way)
regards,
Thierry Poels.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-30-2004 05:49 PM
тАО12-30-2004 05:49 PM
Re: Crontab in korn shell?
#!/bin/sh
UNIX will attempt to execute the file in the current shell, and try to process the included command strings within the file using the syntax rules of the current shell.
So, if you are using the Bourne Shell as your default environment and the ASCII file contains a list of UNIX command structures formatted how the Bourne Shell likes them to be formatted, all will work fine.
However, if you try and execute a C Shell file with a different syntax structure, the Operating System will complain about unrecognised commands and syntax errors.
sks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-30-2004 05:56 PM
тАО12-30-2004 05:56 PM
Re: Crontab in korn shell?
It seems strange, I have done wat you say, but the script cant seem to run well in crontab, however if u execute it from the command line, it works without any problem.. can you think of any reason for this?
***It goes directly to the second while loop ignoring the first one..
regards
Henry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-30-2004 06:04 PM
тАО12-30-2004 06:04 PM
Re: Crontab in korn shell?
I guess the difference is the "current directory".
Some files are put in the current directory as no full path is supplied. When the job is started through cron it is started in the user's home directory. Where did your run the job manually?
regards,
Thierry.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-30-2004 08:07 PM
тАО12-30-2004 08:07 PM
Re: Crontab in korn shell?
5 * * * * /usr/bin/ksh /users/tester/BACKUP_LOG/main.sh
In main.sh cript you specify ksh by
#!/usr/bin/ksh
....contents of main.sh...
...
Best regard.
PS: You should refer (Shell Basic Guide)
http://www.docs.hp.com/en/B2355-90046/index.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-30-2004 11:33 PM
тАО12-30-2004 11:33 PM
Re: Crontab in korn shell?
one thing that could cause a problem is the first of these three lines:
find $SDT > map2.txt
diff $MAP2 $MAP1 > $DMAP
cp $MAP2 $MAP1
where the find command produces output in the current directory - whatever that might be - and perhaps it should have been put elsewhere, e.g.:
find "$SDT" > $MAP2
Just a suggestion....
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-31-2004 02:54 AM
тАО12-31-2004 02:54 AM
Re: Crontab in korn shell?
- /bin doesn't exist in HP-UX and hasn't been there for more than a decade. Just like Solaris and other SysV flavors of Unix that adopted the V.4 filesystem layout standard, the correct directory is /usr/bin. /bin (and /lib) in HP-UX are actually temporary symbolic links that may not be installed automatically in future versions. The HP-UX POSIX shell (which is *NOT* the Bourne shell) is actually a superset of Korn shell. In facr, Korn, BASH and HP's POSIX shell are all "POSIX" shells and virtually identical for shell scripting. The real Bourne shell is located in /usr/old/bin/sh.
- As mentioned, the desired interpreter is used when the (strongly recomended) standard #! line is used in every script. This allows any interpreter (/usr/bin/sh, /usr/bin/ksh, /opt/perl/bin/perl, /usr/local/bin/bash, etc) to be used at either a shell prompt or in an at or cron job.
- The cron environment is VERY different than your login shell. cron does not login and therefore /etc/profile and .profile are not executed and you'll end up with:
HOME=user's-home-directory
LOGNAME=user's-login-id
PATH=/usr/bin:/usr/sbin:.
SHELL=/usr/bin/sh
That's from the crontab man page. That's why your script isn't working the same way--it depends on your login shell environment.
So when you write scripts for cron:
- Always include #! as line 1 with the dfesired interpreter. cron will start your script with the POSIX shell, then switch (if necessary) based on line 1.
- Always hardcode your PATH inside the script. Never include directories you don't need and never include . or .. for file references. Always use fullpathnames for files so there is no ambiguity about exactly what you want.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-02-2005 05:12 PM
тАО01-02-2005 05:12 PM
Re: Crontab in korn shell?
cron itself uses Posix, with no environment. On a day to day basis our cron runs posix jobs, korn shell jobs and a few c shell and bsh jobs that certain applications require.
It all works, last time I checked the cron log.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com