LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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 12-12-2013, 01:37 PM   #1
5883
Member
 
Registered: Aug 2004
Posts: 173

Rep: Reputation: 0
Perl script not running in cron


yes i've googled and problem is still there.

i have a perl build script in ubuntu, want to setup nightly build.
it does work fine if i run it manually.
This build script calls multiple scripts/Makefiles as well.

if just edit "crontab -e", need to manually pay full path for binaries.
Since too many files, i just cannot do it by hand.

if use the GUI gnome-schedule, still stops in the middle of the build.

This is too much for a simple cron task.

Any suggestions ?
 
Old 12-12-2013, 01:47 PM   #2
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD
Posts: 2,131

Rep: Reputation: 333Reputation: 333Reputation: 333Reputation: 333
Runs for the command line manual, not from cron - it is always an environment problem.

If you can't set your fully qualified pathnames, other variables, etc., because there are too many of them scattered about, you can run your profile as part of the cron entry.

e.g.,

Code:
1 0 * * * . /home/mylogin/.profile; /home/mylogin/bin/the_script 2>&1 1>/tmp/captured_crontab_output.txt
Change the pathnames and filenames to match your specifics. Make sure your profile behaves appropriately if a TTY is not connected to stdin, as will be the case if you source it from a crontab entry.
 
3 members found this post helpful.
Old 12-13-2013, 08:52 AM   #3
5883
Member
 
Registered: Aug 2004
Posts: 173

Original Poster
Rep: Reputation: 0
Added path,
now the issue is in my side is the makefile.

App: update
uboot
app-clean
./image_build


the crontab invoked this script which calls the "make App | tee build.log".
But seems it stopped after "make uboot".
If environment is not correct, it cannot build the 1st and 2nd target (update, uboot).
No error msg in the end of build.log, so i don't understand why it stopped there.

Any suggestions pls ?



Quote:
Originally Posted by haertig View Post
Runs for the command line manual, not from cron - it is always an environment problem.

If you can't set your fully qualified pathnames, other variables, etc., because there are too many of them scattered about, you can run your profile as part of the cron entry.

e.g.,

Code:
1 0 * * * . /home/mylogin/.profile; /home/mylogin/bin/the_script 2>&1 1>/tmp/captured_crontab_output.txt
Change the pathnames and filenames to match your specifics. Make sure your profile behaves appropriately if a TTY is not connected to stdin, as will be the case if you source it from a crontab entry.
 
Old 12-13-2013, 11:31 AM   #4
5883
Member
 
Registered: Aug 2004
Posts: 173

Original Poster
Rep: Reputation: 0
it's working now, for some reason, "/home/mylogin/.bashrc;" doesn't work, so i just add paths before i run the script.

last time there was 1 path missing, and i cannot tell from log file.
this time just manually add all paths from .bashrc, so far so good.

thanks !



Quote:
Originally Posted by haertig View Post
Runs for the command line manual, not from cron - it is always an environment problem.

If you can't set your fully qualified pathnames, other variables, etc., because there are too many of them scattered about, you can run your profile as part of the cron entry.

e.g.,

Code:
1 0 * * * . /home/mylogin/.profile; /home/mylogin/bin/the_script 2>&1 1>/tmp/captured_crontab_output.txt
Change the pathnames and filenames to match your specifics. Make sure your profile behaves appropriately if a TTY is not connected to stdin, as will be the case if you source it from a crontab entry.
 
Old 12-13-2013, 01:18 PM   #5
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD
Posts: 2,131

Rep: Reputation: 333Reputation: 333Reputation: 333Reputation: 333
Quote:
Originally Posted by 5883 View Post
it's working now, for some reason, "/home/mylogin/.bashrc;" doesn't work...
That's because you need "<DOT> <SPACE> /home/mylogin/.bashrc". That is how you correctly source a file into your environment. Without the leading <DOT> <SPACE>, it doesn't work. It would have been easy to miss that subtlety in my original example (it's there, but I see how you could have overlooked it).

As in :
Code:
. /home/mylogin/.bashrc
Glad to hear you got it working in another way though.
 
  


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
Cron doesn't work for Perl script Ale87zorg Linux - Server 9 10-10-2012 04:46 PM
Cron Email Notification - Perl Script jamesyreid Programming 3 07-21-2009 08:56 AM
adding a perl script to cron.daily / cron.d to setup a cron job CrontabNewBIE Linux - Software 6 01-14-2008 09:16 AM
Errors when running Perl script in a cron job meshach Slackware 2 06-20-2006 10:10 PM
cron: problem with perl script Clemente Linux - Software 4 05-10-2006 03:30 PM


All times are GMT -5. The time now is 09:04 PM.

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