- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Run crontab job
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-2007 09:50 PM
05-17-2007 09:50 PM
Re: Run crontab job
What I hope now is when when run a script by crontab , the env will change to env_cron( see below ) , I don't know why this program is not work , can anyone advise what is wrong ? thx
for i in $(cat /tmp/env_cron)
do
export ${i}
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2007 08:53 AM
05-18-2007 08:53 AM
Re: Run crontab job
You will need to show a few lines of env_cron.
But one issue could be due to embedded blanks if you have: XXX=abc def
You can improve your script by removing the redundant cat:
for i in $(< /tmp/env_cron); do
export ${i}
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2007 12:36 PM
05-18-2007 12:36 PM
Re: Run crontab job
Insteading of doing:
for i in $(cat /tmp/env_cron)
do
export ${i}
done
Whey dont you use source the file in '. /tmp/env_cron' for Bourne/Korn Shells or 'source /tmp/env_cron' for C like Shells.
Do this before running a crontab command or include it inside a script.
But like most have stated, your issue is elsewhere and I am still not clear what the problem is as you've not attempted in tracking it down.
Jov
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2007 03:02 PM
05-20-2007 03:02 PM
Re: Run crontab job
Your suggestion seems very simple ,
I try to write the below script to test it ( I use bash ) , the env (/tmp/check_cron_result
) is still same as that in crontab , can advise what is wrong ? thx
#!/bin/bash
. /tmp/env_cron
env > /tmp/check_cron_result
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2007 03:36 AM
05-21-2007 03:36 AM
Re: Run crontab job
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2007 01:26 PM
05-21-2007 01:26 PM
Re: Run crontab job
I use bash , so when I use "set -x" , there is no output ,
Now. I am strange that why I use the below method ( in crontab ) , the env is still unchange , but it work fine if I run it manually ?
. /tmp/env_cron
env > /tmp/check_cron_result
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2007 02:27 PM
05-21-2007 02:27 PM
Re: Run crontab job
We want to help but you are confusing the heck out of me. First the script was working from cron, but failed manually. Now are suggesting your script works manually, but fails from cron??
Can you clarify this point some we have a better idea of where you're coming from?
set -x works fro bash as well.
Jov
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2007 02:30 PM
05-21-2007 02:30 PM
Re: Run crontab job
Ah, .profile isn't read except by the login shell. So set -x in .profile won't help.
You need to use set -x in your script and see why the output is different. (I guess this was what Clay said way back when.) The -x output goes to stderr.
If this doesn't work, all I can suggest is YOUR bash is broken and use echo statements to track it.
>I use the below method (in crontab), the env is still unchanged, but it work fine if I run it manually?
. /tmp/env_cron
env > /tmp/check_cron_result
This isn't helpful. Please provide the crontab file and script where you do this and what the outputs are. Or provide a diff.
What should happen is all of the ENV VARs you set in your .profile and related files will not be there when run in your crontab.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2007 06:05 PM
05-22-2007 06:05 PM
Re: Run crontab job
Actually , what the problem I want to fix is the script can run manually but can't run by crontab , so now I want to run the script by crontab sucessfully .
I am not too understand what is the function of "set -x" , so I write a program and put it on the top of the script to change the env , I think it it simplest way , however it is not work , don't you think it is a solution of the problem ? if yes , can advise what is wrong ? thx
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2007 09:15 AM
05-23-2007 09:15 AM
Re: Run crontab job
This is the problem we've been telling you that you may have and you've been saying the exact opposite.
>I am not too understand what is the function of "set -x",
One purpose of the set -x was to track down the opposite problem.
>don't you think it is a solution of the problem?
The purpose of "set -x" is to trace the commands in your script to see where it fails.
So, what are the errors you are getting in your crontab script? Do you redirect the crontab output or do you get a mail message?
As mentioned several times, when you execute a script from crontab, you don't have your environment from .profile, unless you do:
$ . ~/.profile
PATH and env vars are limited. Your umask may be incorrect. Your aliases are not present but you shouldn't be depending on them in any script.
- « Previous
-
- 1
- 2
- Next »