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
Solved

Cron environment problem

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

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…
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 …
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

840 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