Solved

Cron environment problem

Posted on 2004-05-03
4
1,099 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Postfix issues with spam/auth attempts under NAT 9 137
awk file 6 102
Linux Desktop suggestion for Dell Inspiron 3043 13 67
exchange, squid, proxy, linux 6 43
Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

733 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