LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > CentOS
User Name
Password
CentOS This forum is for the discussion of CentOS Linux. Note: This forum does not have any official participation.

Notices


Reply
  Search this Thread
Old 05-21-2016, 03:26 AM   #1
Sujith Sagar
LQ Newbie
 
Registered: Feb 2016
Distribution: Cent OS 7.2
Posts: 11

Rep: Reputation: Disabled
I have scheduled cron job but it not running as expected.


I have verified and found that logs are also getting generated,but cron jobs are not getting executed. Somebody can help me regarding this i am totaly new to linux.

Last edited by Sujith Sagar; 05-21-2016 at 03:27 AM.
 
Old 05-21-2016, 04:10 AM   #2
Tonus
Senior Member
 
Registered: Jan 2007
Location: Paris, France
Distribution: Slackware-15.0
Posts: 1,405
Blog Entries: 3

Rep: Reputation: 514Reputation: 514Reputation: 514Reputation: 514Reputation: 514Reputation: 514
I have scheduled cron job but it not running as expected.

Best would be you provide the output of

crontab -l

And the script you are trying to execute.
 
1 members found this post helpful.
Old 05-21-2016, 04:15 AM   #3
Sujith Sagar
LQ Newbie
 
Registered: Feb 2016
Distribution: Cent OS 7.2
Posts: 11

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Tonus View Post
Best would be you provide the output of

crontab -l

And the script you are trying to execute.

Hi,

Here is the output of the crontab -l

[root@test lib]# crontab -l
1 * * * * /home/ssagar/cronnew.sh


And the script is

echo "welocme" >> output.txt

The above script was simple as i am trying to test whether cron is working or not. When i execute the above script manually it will be successfully executed.

Last edited by Sujith Sagar; 05-21-2016 at 04:17 AM.
 
Old 05-21-2016, 05:17 AM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,702

Rep: Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896
You should use an absolute path to your output file.

echo "welcome" >> /home/ssagar/output.txt
 
1 members found this post helpful.
Old 05-21-2016, 05:20 AM   #5
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,309
Blog Entries: 3

Rep: Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721
You might try using an absolute path for your output.txt file, so that you know for sure where it ends up when the script is run by cron.

Edit: oops, too slow. If you want to see what cron has for settings, add the following line to your script and look for the output in /tmp/settings.txt

Code:
set > /tmp/settings.txt

Last edited by Turbocapitalist; 05-21-2016 at 05:23 AM.
 
Old 05-22-2016, 02:00 AM   #6
Sujith Sagar
LQ Newbie
 
Registered: Feb 2016
Distribution: Cent OS 7.2
Posts: 11

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by michaelk View Post
You should use an absolute path to your output file.

echo "welcome" >> /home/ssagar/output.txt
Hi,

Hi have tried as mentioned above but still cron job is not getting executed.
 
Old 05-22-2016, 05:07 AM   #7
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,475

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
Ensure that /home/ssagar/cronnew.sh has execute permissions, also when were you expecting this to run?

Your cron job sets it to run once an hour at 1 minute past the hour.
 
Old 05-22-2016, 08:10 AM   #8
Tonus
Senior Member
 
Registered: Jan 2007
Location: Paris, France
Distribution: Slackware-15.0
Posts: 1,405
Blog Entries: 3

Rep: Reputation: 514Reputation: 514Reputation: 514Reputation: 514Reputation: 514Reputation: 514
I have scheduled cron job but it not running as expected.

To check my cron jobs, I use to run the script with

Code:
 
command xx && DISPLAY=:0 notify-send "OK" "command xx" || DISPLAY=:0 notify-send --urgency=critical "FAILED" "command xx"
 
Old 05-22-2016, 08:16 AM   #9
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~amd64
Posts: 7,661

Rep: Reputation: Disabled
You may need to use /bin/echo instead of plain echo.
 
  


Reply

Tags
cron



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help with a scheduled reboot cron job via Webmin torbuck Linux - Newbie 10 06-18-2017 10:56 PM
Cron job scheduled to the server after logging in via ssh login doest not run surekag Linux - Newbie 4 02-12-2014 08:15 AM
[SOLVED] Running scheduled script with cron snadjari Linux - Newbie 5 03-04-2011 02:39 PM
Webmin - Scheduled Cron Job - Password! tfranklin Linux - Server 5 01-20-2010 07:08 PM
What does cron do if machine is down when job is scheduled? Utah Linux - Software 4 08-24-2005 07:23 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > CentOS

All times are GMT -5. The time now is 05:54 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
Open Source Consulting | Domain Registration