LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 11-14-2011, 08:20 AM   #1
edpudol
LQ Newbie
 
Registered: Nov 2011
Posts: 6

Rep: Reputation: Disabled
Help with my cron job please


I have this two codes the first one works fine to my site but the second code not working.

Will you please help me to figure out why the second cron job is not working. The script is working fine if I open it from browser.

0,30 * * * * cd /home/user/folder/; /usr/bin/php index.php
* * * * * curl -s http://www.domain.ph/script.php?type=close

Thank you very much in advance for the help

Last edited by edpudol; 11-14-2011 at 09:51 PM.
 
Old 11-14-2011, 08:43 AM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,635

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by edpudol View Post
I have this two codes the first one works fine to my site but the second code not working.

Will you please help me to figure out why the second cron job is not working. The script is working fine if I open it from browser.

0,30 * * * * cd /home/user/fp;der/; /usr/bin/php index.php
* * * * * curl -s http://www.domain.ph/script.php?type=close

Thank you very much in advance for the help
Neither of those commands are scripts, and I've no idea what you're trying to do.

The first command (cd /home/user/fp...line), isn't going to do ANYTHING except change a directory, unless the "der" statement is a script somewhere on your path. The second part of it will run index.php...but can't figure out why you'd do that.

The second command (curl...), may need double-quotes around it, but again, I can't see what you're trying to accomplish with this, either, and based on how you've got it structured, it's going to run constantly. Also, it's not going to put output of that command into your home directory, but (since I'm assuming you're doing this through root cron), but have you checked the cron logs and/or the root home directory for the output?

If it was me, I'd re-write the first line, and have one script file that does the cd, run the der command, then run index.php. And the second I'd have a script run at system-startup time, which simply sleeps for 60 seconds, and loops back through and runs again...cron is overkill for an every-minute task.
 
Old 11-14-2011, 09:02 AM   #3
rodrifra
Member
 
Registered: Mar 2007
Location: Spain
Distribution: Debian
Posts: 202

Rep: Reputation: 36
Forget this answer I was wrong.

Last edited by rodrifra; 11-14-2011 at 09:07 AM. Reason: Wrong answer
 
Old 11-14-2011, 09:54 PM   #4
edpudol
LQ Newbie
 
Registered: Nov 2011
Posts: 6

Original Poster
Rep: Reputation: Disabled
TB0ne thanks for the answer, if I put double does the command line look like this curl -s "http://www.domain.ph/script.php?type=close" or "curl -s http://www.domain.ph/script.php?type=close"

The first code is just a test cron job to check cron job is working in my server, the script will record the time every time the cron job is process and found out working.

But the second code for what ever reason it does not return the result. I don't if the there is a problem with the curl or on my server.
 
Old 11-14-2011, 09:58 PM   #5
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by edpudol View Post
TB0ne thanks for the answer, if I put double does the command line look like this curl -s "http://www.domain.ph/script.php?type=close" or "curl -s http://www.domain.ph/script.php?type=close"
The first because it runs curl; the second tries to run a command which is the entire string.
 
Old 11-14-2011, 10:16 PM   #6
edpudol
LQ Newbie
 
Registered: Nov 2011
Posts: 6

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by catkin View Post
The first because it runs curl; the second tries to run a command which is the entire string.
Thanks mate but still no success...
 
Old 11-14-2011, 10:24 PM   #7
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
To repeat what TBOne wrote and you did not respond to: is this a root cron job? Have you checked the cron logs and/or the root home directory for the output?

Have you checked root's mail?

Try * * * * * curl -s http://www.domain.ph/script.php?type=close >/tmp/some-name-nothing-else-would-use 2>&1
 
Old 11-15-2011, 04:28 AM   #8
edpudol
LQ Newbie
 
Registered: Nov 2011
Posts: 6

Original Poster
Rep: Reputation: Disabled
Thanks for all the help but still no success , the cron job is for my website not for root. I tried catkin solution but still not working

Does the following cron job command
curl -s http://www.domain.ph/daemons.php?type=extend

the same with
cd /home/folder/public_html/; /usr/bin/php daemons.php?type=extend

My purpose with this cron job is to run this script every minute...

Last edited by edpudol; 11-15-2011 at 04:53 AM.
 
Old 11-15-2011, 04:37 AM   #9
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Have you checked the cron logs, the home directory of the user cron is running this for and the mail of both root and the user cron is running this for?

My suggestion was not so much intended to get the cron job working as to capture any stdout and stderr output from it. Was file /tmp/some-name-nothing-else-would-use (or whatever you called it) created? Did it have anything in it?

You will have to get better at answering questions if we are to solve this quickly.
 
Old 11-15-2011, 05:02 AM   #10
edpudol
LQ Newbie
 
Registered: Nov 2011
Posts: 6

Original Poster
Rep: Reputation: Disabled
Hi here is the result from the cron logs

Nov 15 12:23:01 panalo CROND[21718]: (username) CMD (curl http://www.site.ph/daemons.php?type=close)
Nov 15 12:23:01 panalo CROND[21719]: (username) CMD (curl http://www.site.ph/dwinner)
Nov 15 12:23:01 panalo CROND[21723]: (username) CMD (curl http://www.site.ph/dcleaner)
Nov 15 12:23:01 panalo CROND[21724]: (username) CMD (curl http://www.site.ph/daemons.php?type=extend)
Nov 15 12:23:01 panalo CROND[21725]: (username) CMD (curl http://www.site.ph/daemons.php?type=bidbutler)
 
Old 11-15-2011, 08:17 AM   #11
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,635

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by edpudol View Post
Thanks for all the help but still no success , the cron job is for my website not for root. I tried catkin solution but still not working

Does the following cron job command
curl -s http://www.domain.ph/daemons.php?type=extend

the same with
cd /home/folder/public_html/; /usr/bin/php daemons.php?type=extend
My purpose with this cron job is to run this script every minute...
Again, I'll say that you should put this command into it's OWN SCRIPT FILE, and call IT through cron. You can direct the output easier, and debug it easier that way.
 
Old 11-16-2011, 12:16 AM   #12
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
curl is probably not in the PATH in the cron env; always use complete paths for cmds & files if calling direct from cron, else (as recommend) create a script, call it in cron and inside the script set any vars reqd.
 
  


Reply



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 job deeppal123 Linux - Newbie 11 03-22-2011 08:08 AM
linux cron job duplicate job question cpthk Linux - Newbie 4 09-11-2009 08:52 PM
adding a perl script to cron.daily / cron.d to setup a cron job CrontabNewBIE Linux - Software 6 01-14-2008 08:16 AM
Cron Job petenyce Linux - Newbie 5 10-11-2005 04:03 PM
need help with cron job parthcorp1 Linux - General 2 02-01-2005 11:37 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

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