Solved

Cron environment problem

Posted on 2004-05-03
4
1,091 Views
Last Modified: 2012-05-04
Hi!

i'm trying to execute a perl script via crontab, this perl script contains some unix's commands execution inside it. When i execute this script from Linux command line it works fine, but when i insert it as a cron job, it returns me a mail with this:

From root@mobydick.xxxx.net  Mon May  3 15:58:42 2004
X-Original-To: root
Delivered-To: root@mobydick.xxxx.net
From: root@mobydick.xxxx.net (Cron Daemon)
To: root@mobydick.xxxx.net
Subject: Cron <root@mobydick> /root/quotas.pl
X-Cron-Env: <SHELL=/bin/bash>
X-Cron-Env: <PATH=/sbin:/usr/sbin:/usr/local/sbin:/root/bin:/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/usr/games:/opt/gnome/bin>
X-Cron-Env: <HOME=/>
X-Cron-Env: <LOGNAME=root>
Date: Mon,  3 May 2004 15:58:42 +0200 (CEST)

sh: line 1: /bin/quota*: cannot execute binary file

* /bin/quota is called from my script.

This is my /var/spool/cron/tabs/root:

# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.22842 installed on Mon May  3 15:53:03 2004)
# (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)
SHELL=/bin/bash
PATH=/sbin:/usr/sbin:/usr/local/sbin:/root/bin:/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/usr/games:/opt/gnome/bin
HOME=/
57 15,22 * * * /root/quotas.pl

Thanks in advance!
0
Comment
Question by:morsa801tons
  • 2
  • 2
4 Comments
 
LVL 40

Expert Comment

by:jlevie
ID: 10977967
Is the first line of your Perl script "#!/usr/bin/perl"? There can be no leading or trailing white space and that line must be terminated only by a new-line character.
0
 

Author Comment

by:morsa801tons
ID: 10978140
yes, my script starts like this:

#!/usr/bin/perl

# using the perl-MySQL module
use DBI;
use CGI;
my $cgiobject=new CGI;
# print $cgiobject->header();

#   Database Name
$database="quotas";

#  HostName of the MySQL Server. HostName of the Remote
# MySQL server also can be used.
$hostname="localhost";
# Port name on which MySQL server is running.
$port=3306;
# User Name who has the access to manipulate the mentioned
# database.
0
 

Author Comment

by:morsa801tons
ID: 10978307
And this is quota's content:

/bin/echo "Tamaño de las cuentas de correo en Kb:"
/usr/bin/du /mail --max-depth=2|/bin/sort -rn|/bin/more
/bin/ls /mail/xxxx.net/ -tl|/usr/bin/cut -b 44-|/bin/more

0
 
LVL 40

Accepted Solution

by:
jlevie earned 250 total points
ID: 10978355
So the Perl code is attempting to execute a set of shell commands in an external file? To do that the script file
needs to begin with "#!/bin/sh"
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now