Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cron environment problems 4

Status
Not open for further replies.

zifko

Technical User
Oct 9, 2002
10
0
0
Hi!

Need help! I wrote a perl script which I want start with cron from a linux system. If I start the perl script in a console, it works well. The script isn`t stored in the home directory from the user. If I run my script from the cron, there are som failures that the script doesn`t find some files, because the files are in a other directory than home directory.
Is there a possibility in kind of starting of the script to give the cron the directory, where the perl script has its corresponding files?
 
can you not chdir "directory"; at the start of the Perl script?


Kind Regards
Duncan
 
great. so easy! it works well.

I have another question. Maybe, you can help me again?
With every execution of my perl script via cron, there is a mail with the console-output from my perl script. How can I eleminate these mails from the cron job?
 
First point, if duncdude helped you, why not thank him with a star?
Second issue, redirect the stdout to /dev/null like this:
Code:
perl perlscript.pl > /dev/null
That should stop the emails (unless the script outputs anything to stderr).
If you don't want emails with stderr error messages either then do this:
Code:
perl perlscript.pl > /dev/null 2>&1


Trojan.
 
Thank you Trojan!

By the way - i love that advice regarding the emails... i just got a call from my ISP as my a/c had 2 gigs of shite in there. I shall be giving that a go!

A star for you!


Kind Regards
Duncan
 
Different kind of emails!
These are emails from "cron" for processes.
But there are many ways to get rid of junk emails.
Maybe you need to take my star back then!
Anyway, you were the one supposed to get the star, so have one from me. I appreciate your efforts! ;-)


Trojan.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top