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 03-08-2016, 03:05 AM   #1
Dustin Cook
Member
 
Registered: Feb 2015
Posts: 31

Rep: Reputation: Disabled
Make Commands Executed Through Cron


Hello!

I have a question regarding running make commands through a scheduled cron job which runs a shell script.

The shell script contains commands that I execute to make a binary file. When I execute the commands manually, it produces a binary file that is 29MB in size.

When I look at the binary file size when the commands are executed through the cron job, this binary file then becomes 16MB in size.

I am running Ubuntu 14.04.4 LTS, 32-bit operating system.

Any suggestions as to what is causing the issues?
 
Old 03-08-2016, 10:44 AM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,075
Blog Entries: 14

Rep: Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251
Have a look at this blog post:

http://www.linuxquestions.org/questi...-script-36931/
 
1 members found this post helpful.
Old 03-08-2016, 10:51 AM   #3
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,561

Rep: Reputation: 2127Reputation: 2127Reputation: 2127Reputation: 2127Reputation: 2127Reputation: 2127Reputation: 2127Reputation: 2127Reputation: 2127Reputation: 2127Reputation: 2127
Make sure you're using absolute paths to everything in your script and redirect the output of the script to a log file so you can check for any odd behavior.
 
Old 03-08-2016, 12:44 PM   #4
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,075
Blog Entries: 14

Rep: Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251
Quote:
Originally Posted by suicidaleggroll View Post
Make sure you're using absolute paths to everything in your script and redirect the output of the script to a log file so you can check for any odd behavior.
You don't have to use absolute paths. You can set the PATH variable within the script as discussed in the blog link.

Redirecting to a log is a good idea.
 
Old 03-08-2016, 12:55 PM   #5
JockVSJock
Senior Member
 
Registered: Jan 2004
Location: SATX
Distribution: RHEL/CentOS
Posts: 1,233
Blog Entries: 4

Rep: Reputation: 135Reputation: 135
White space is the big issue for me, which is empty characters behind code. Make sure you eliminate it.


From vi/vim

Code:
:set line

Last edited by JockVSJock; 03-08-2016 at 01:01 PM.
 
Old 03-09-2016, 04:01 AM   #6
Dustin Cook
Member
 
Registered: Feb 2015
Posts: 31

Original Poster
Rep: Reputation: Disabled
Thanks everyone for your input. The solution was somewhat more simple:

Code:
30 14 * * * bash -lc /location/of/script.sh
I added the "bash -lc" argument to the crontab file.

I don't like not knowing, so any anyone explain why adding this fixed my problems?
 
Old 03-09-2016, 04:18 AM   #7
OregonJim
Member
 
Registered: Feb 2016
Posts: 98

Rep: Reputation: Disabled
Quote:
Originally Posted by Dustin Cook View Post
Thanks everyone for your input. The solution was somewhat more simple:

Code:
30 14 * * * bash -lc /location/of/script.sh
I added the "bash -lc" argument to the crontab file.

I don't like not knowing, so any anyone explain why adding this fixed my problems?
Probably because it modified the script's runtime evironment by processing /etc/profile and /etc/bashrc.

You can see what's different by logging the output of "env" from your script, both with and without bash.

Last edited by OregonJim; 03-09-2016 at 04:20 AM.
 
1 members found this post helpful.
Old 03-09-2016, 04:35 AM   #8
Dustin Cook
Member
 
Registered: Feb 2015
Posts: 31

Original Poster
Rep: Reputation: Disabled
Ah so after some digging I found this:

Code:
bash -c
If the -c option is present, then commands are read from string. If there are arguments after the string, they are assigned to the positional parameters, starting with $0.
Code:
bash -l
Make bash act as if it had been invoked as a login shell.

There we have it mystery solved. Just doing a final test of my script before leeting it run automatically from today onwards.

Thanks everyone for your input!
 
  


Reply

Tags
cron, make


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
Script not getting executed via CRON getraj.12 Linux - Newbie 11 02-10-2015 02:25 PM
[SOLVED] Configured Cron job executed every hour is instead executed every minute for 10m markings Linux - Software 4 05-13-2012 06:43 PM
how can we know whether a Cron job has been executed or not ?? vikas027 Linux - Server 6 04-17-2009 02:49 PM
script not executed by cron.daily hopefull Linux - Newbie 6 01-17-2009 10:54 AM
Cron jobs are not getting executed sharu99 Programming 17 11-04-2008 01:04 AM

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

All times are GMT -5. The time now is 10:04 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