Re: Cannot execute /usr/bin/fetchmail

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Sun, 2007-03-25 at 18:48 +0800, Matt Arnilo S. Baluyos (Mailing
Lists) wrote:
> Hello everyone,
> 
> I'm setting up a fetchmail command to run every five minutes so I can
> get email from another POP3 account. The fetchmail package was
> installed via yum.
> 
> I can execute the command manually on the command line. But I'm having
> trouble when it's run from cron.
> 
> I have noticed that commands run via cron and execute via /bin/sh, so
> I tried to run the fetchmail command manually. This is what I get:
> 
> [root@scalix ~]# /bin/sh /usr/bin/fetchmail
> /usr/bin/fetchmail: /usr/bin/fetchmail: cannot execute binary file
> 
> What could be the problem here? Anyone else having problems with fetchmail?
> 

Going from memory, so I hope this is not too erroneous.

As you may have deduced from the other replies, you don't *need*
"/bin/bash" at the start of the command line when executing a typical
binary.

Even for cron entries.

The linker/loader has some logic to automatically handle various binary
formats. In fact, AFAIR, the convention of the first line in a shell
script having something like "#!/bin/bash" was to allow this same
"automatic" loading to occur. I've never followed up to see if any OS
implementation actually handles it correctly. I presume that a program
would call the loader and pass the file name to get it to work, if it
does indeed work.

Further, I believe that normal shell scripts don't need the leading
"/bin/sh" (or similar) either. As another respondent pointed out, the
default is to execute via "/bin/sh -c ...." or similar. For binaries,
this does interject a small amount of additional overhead. It is not
significant.

One point of significance: the environmental variables that exist at
command line do/may not be set/correct when crontab invokes a process.
For this reason, some binaries may need a "wrapper" script that is
called by cron. It may be as simple as #!/bin/bash --login... some more
stuff" or even just contain "." (or "source", if you prefer) command to
read the appropriate .bashrc or .bash_profile to inject needed variables
into the environment.

HTH
--
Bill

_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos

[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux