LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 10-15-2009, 03:45 PM   #1
bartonski
Member
 
Registered: Jul 2006
Location: Louisville, KY
Distribution: Fedora 12, Slackware, Debian, Ubuntu Karmic, FreeBSD 7.1
Posts: 443
Blog Entries: 1

Rep: Reputation: 48
testing shell scripts before entry into crontab.


I'm trying to run a cron job which calls a shell script that runs several queries against an Oracle database. I'm getting emails telling me that there are environment variables which are not set.

I would like to run the shell script in an environment which is as close as possible to how cron runs the script (except that I would actually like to see stdout and stderr, rather than having them echo to an email message).

I'm guessing that something like

Code:
sh --noprofile myscript.sh
should pretty well do the trick, but I may be missing something.

Also, is there a way to lauch a crontab entry manually, as if cron had just fired off? (yes, I know that I can set cron to fire off every minute, but that destroys my work flow).
 
Old 10-15-2009, 08:28 PM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,358

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
This page explains how to set env vars in your cron job, and which ones are (usually) set by default.
http://linux.die.net/man/5/crontab
The easiest soln is not to set them in the crontab, because you may have several different programs in there.
For a given job, set them at the top of the script.
Always use complete absolute paths to any cmds/files referenced, as the default cron env is minimal (see manpages).
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
about crontab entry Ravi kumar Linux - Software 2 09-16-2008 01:41 PM
Somehow not getting crontab entry right Jykke Linux - Desktop 4 02-29-2008 01:50 PM
Crontab entry updation prob in different shell hinetvenkat Solaris / OpenSolaris 3 11-01-2006 09:56 AM
crontab entry? Master Fox Linux - Software 4 08-23-2005 01:20 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 03:38 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration