Solved

Cron environment problem

Posted on 2004-05-03
4
1,087 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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
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…
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.

707 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

16 Experts available now in Live!

Get 1:1 Help Now