LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   C++ prorgam runs OK from command line, but failed from crontab (https://www.linuxquestions.org/questions/linux-software-2/c-prorgam-runs-ok-from-command-line-but-failed-from-crontab-280236/)

vgolden 01-20-2005 03:39 PM

C++ prorgam runs OK from command line, but failed from crontab
 
I have fairly large C++ program which we ported from NT. I compiled it on RedHat Linux as:

c++ -Wno-deprecated -static -o <prog_name> -x c++ *.cpp

than it is called from the shell script.

When I execute shell script from the command line C++ program runs just fine. Horever, when the same shell script run from the crontab, C++ failed with:

2831 Segmentation fault

It even not attempting to run!

Any ideas? Any help will be greatly appreciated

leonscape 01-20-2005 06:25 PM

Perhaps something in the enviroment is not set whne you use cron, but it is set when you run from shell. Home directory, it expects to executed from a certain place? Do you have absolute or relative paths coded in?

wpn146 01-21-2005 11:00 AM

Re: C++ prorgam runs OK from command line, but failed from crontab
 
Quote:

Originally posted by vgolden
I have fairly large C++ program which we ported from NT. I compiled it on RedHat Linux as:

c++ -Wno-deprecated -static -o <prog_name> -x c++ *.cpp

than it is called from the shell script.

When I execute shell script from the command line C++ program runs just fine. Horever, when the same shell script run from the crontab, C++ failed with:

2831 Segmentation fault

It even not attempting to run!

Any ideas? Any help will be greatly appreciated

cron generally runs commands from the "sh" shell but when you run it from the command line it runs from whatever shell you are using. Are you using a "bang line" like "#!/bin/csh" or "#!/bin/bash"as the first line of the shell script you are trying to run? This should make the results the same whether you run under cron or the command line. (Of course, that may mean it fails under both too!)


All times are GMT -5. The time now is 01:37 AM.