Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Cron environment problem

Posted on 2004-05-03
4
Medium Priority
?
1,113 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 1000 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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
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…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Suggested Courses
Course of the Month9 days, 10 hours left to enroll

877 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