LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-08-2012, 03:59 PM   #1
stevieger
LQ Newbie
 
Registered: Nov 2012
Posts: 2

Rep: Reputation: Disabled
crontab syntax or...?


I'm trying to setup a crontab and I've never done this before but I've created a simple perl script and I'd like it to be run every minute.

I create a file cron.txt containing:
Quote:
* * * * * /directories to script/perl script.pl > /dev/null 2>&1
(blank line here)
I then enter the command: crontab cron.txt
then I enter: crontab -l
no complaints everything seems fine however the perl script is not executing...I enter the same command myself "perl script.pl" and it does what it's supposed to do.

I'm attempting to do this on a UNIX solaris box, any insight is greatly appreciated, thanks.

Steve
 
Old 11-08-2012, 04:17 PM   #2
linosaurusroot
Member
 
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 982
Blog Entries: 2

Rep: Reputation: 244Reputation: 244Reputation: 244
How do you now it's not executing? Does the code below show the timestamp updating?
Code:
while ls -lu "/directories to script/perl script.pl"
do
date
sleep 30
done
Is the filename free of spaces as would be normal?

You don't know what's happening because of throwing away your error messages - enable these at least until you know it is working.

Are there differences in the environment between your interactive shell and cron that would affect whether it works?
 
Old 11-08-2012, 04:43 PM   #3
stevieger
LQ Newbie
 
Registered: Nov 2012
Posts: 2

Original Poster
Rep: Reputation: Disabled
I don't actually know that it isn't trying to execute, but the script begins by reading in a file and then deleting it and that is not happening so I know that it's not getting that far at least.

The file name is free of spaces it is and directories are as well.

I'll have to enable the error messages and see what it gives.

And I'm not sure how to tell if there are environment differences between the shell and cron but I will look into it.

Thanks.
 
Old 11-08-2012, 04:51 PM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 16,430

Rep: Reputation: 1938Reputation: 1938Reputation: 1938Reputation: 1938Reputation: 1938Reputation: 1938Reputation: 1938Reputation: 1938Reputation: 1938Reputation: 1938Reputation: 1938
Yes there are differences. cron has a limited environment and does not know the the path to the perl interpreter. Does your script have the perl shebang? (#!/usr/bin/perl) Its been awhile since I've played with solaris and do not remember its path. Make your script executable and then all you need in cron is:

/path/to/script.pl > /dev/null 2>&1
 
Old 11-08-2012, 08:09 PM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,417

Rep: Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397
Have you checked /var/log/cron to see if its being called?
As above, enable stdout+stderr to file
Normally if cron has a problem, it will email the job owner or root.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] crontab .jar syntax sueco Programming 3 08-24-2012 01:27 PM
crontab syntax question kaplan71 Linux - General 2 01-25-2010 11:35 AM
Correct syntax for days in crontab kaplan71 Linux - General 1 03-12-2009 01:46 PM
Linux Crontab Syntax shritesh Linux - Software 1 01-03-2007 03:43 AM
crontab syntax niehls Linux - General 1 03-08-2003 12:51 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:42 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration