LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices


Reply
  Search this Thread
Old 02-19-2006, 09:43 PM   #1
w3developing
LQ Newbie
 
Registered: Jan 2006
Posts: 10

Rep: Reputation: 0
CRON job creations w/ ssh


I need to set up 4 crons in relation to 4 .php files. I have root access. The .php files are under a specifc web account that I created in WHM, so I can just ssh into that account. What I do not know for sure is:

1.) what directory should the crons be created in?

2.) what is my full path typed out? like: home/www/??

Below is an instruct that I had previously, but I was unsure of my full path like /local/www/?
=======================================================
Important: First find the path to your PHP executable

# whereis php

Then add full path in crontab

example:

# crontab -e
-- run midnight
0 0 * * * /usr/local/bin/php /local/www/something.php
-- run every 5 minutes
*/5 * * * * /usr/local/bin/php /local/www/something.php
-- run every 5 hours
* */5 * * * /usr/local/bin/php /local/www/something.php
=======================================================

Please any help on this. I can provide as much info as needed.
 
Old 02-20-2006, 05:37 PM   #2
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,141

Rep: Reputation: 168Reputation: 168
For question 1, I don't think you need to worry about the path of the crontab file. Using the crontab -e command on my system automatically opens my crontab under /var/spool/cron.

For question 2, whereis php will provide the location of the php executable. If you don't know the location of the web files, something like the following should provide it (substitute the name of one of your php files for filename.php):
Code:
find / -type f -iname 'filename.php' 2>/dev/null
Is that what you were looking for?
 
Old 02-21-2006, 01:02 AM   #3
w3developing
LQ Newbie
 
Registered: Jan 2006
Posts: 10

Original Poster
Rep: Reputation: 0
Thanks gilead, I having a hell of a time, cause the instruct I had from before is not seeming to line up properly. Here is what I am doing, and then the results in by-step order:

1.) login ssh

2.) this displays ==> myaccount@myaccount.com [~]#

3.) i then type "ls" to see where i am at

4.) lists dirs

5.) i then go "cd public_html/cron"

6.) now i see --> [~/public_html/cron]#

im now in the dir of my .php files. at this point type "crontab -e"

now i have a basically blank screen with ( at the footer ):

[ Read 0 line ]
^G Get Help ^O WriteOut ^R Read File ^Y Prev Pg ^K Cut Text ^C Cur Pos
^X Exit ^J Justify ^W Where is ^V Next Pg ^U UnCut Text^T To Spell

i then enter: "**/24** /usr/local/bin/php /local/public_html/cron/deletepublicposting.php"

then i hit Cntrl O to WriteOut - then brought to a page that has this:

=================================================================================================
**/24** /usr/local/bin/php /local/public_html/cron/deletepublicposting.php

File Name to write : crontab.31265
^G Get Help ^T To Files
^C Cancel TAB Complete
=================================================================================================

then i hit "enter" and i am brought back to the above page and a small area says "[ Wrote 1 line ]"

does this mean the cron was added to the correct directory?

I also selected "T" and saw a list of files. Was not sure what to look for?

As you can see I really want to learn UNIX/RedHat techniqus. Please help me out. Has anyone done this before? And help SOS!
 
Old 02-21-2006, 05:24 AM   #4
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,141

Rep: Reputation: 168Reputation: 168
That looks like it's working properly - the part about wrote 1 line is the data being saved. I haven't seen an editing screen like that for a long time, but you'll find out pretty quickly - as soon as the script does or doesn't do what it's supposed to.
 
Old 02-23-2006, 11:06 PM   #5
cramer
Member
 
Registered: Feb 2006
Distribution: Red Hat 9
Posts: 112

Rep: Reputation: 15
Not sure if you are doing it a differnt way, but this is the way I have written to crontab -e before:

type "crontab -e"
press "i" to change to insert mode.
add cron line.
Press enter to go to new line, then press ESC
Press SHIFT + ;
this will skip you down to the bottom, now type "wq!" (without quotes)
This should save your cron properly, to check type "crontab -l" to see it listed.

Also, what user are you logged in as when you assing the cron.

And instead of using ls to find out what dir you are in, you can use "pwd" instead, it will list your current dir.
 
Old 02-26-2006, 01:51 AM   #6
w3developing
LQ Newbie
 
Registered: Jan 2006
Posts: 10

Original Poster
Rep: Reputation: 0
>> cramer: press "i" to change to insert mode.
add cron line.

>> w3developing: can you please clarify what you mean by "i" would I can an "i" on the end of crontab -e?

I am logged in as the user of the account, but I also have root access.

Hope to hear back. Thanks!
 
  


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 not running ssh script karim0028 Linux - General 3 02-07-2005 12:08 PM
CRON Job tommytomato Fedora 12 09-13-2004 12:38 AM
Cron job rajasekarvr Linux - General 4 05-03-2004 05:35 PM
cron job? luap Linux - Software 2 03-16-2003 08:48 AM
Cron job T-Rex Linux - Newbie 1 09-26-2001 11:28 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat

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