Jump to content

cron job on 1and1 server


travelerBT

Recommended Posts

hello freaks!

 

I am new to cron, but I am pretty sure that I have set it up correctly on my 1and1 server.

 

I have this currently in my crontab -l

 

0,15,30,45 * * * * /classes/testEmailScript.php

 

The script works perfectly if I load it in a browser so I know the problem isn't the script... the only thing I can think of is that I have the path to the script wrong????? Any ideas?????  I have also tried it using classes/testEmailScript.php and that didn't work either.

 

Does the cron file need some other path directories in there specific to 1and1 servers?  I have a business server.

 

Any help would be great!! examples??!!

 

thanks again.

Link to comment
Share on other sites

This should do, directly from 1and1:

 

---

Cron jobs can help you to automate certain procedures e.g. backup. This article is

a brief "how-to" for creating a cron field which defines when a specific

application or script should be executed.

 

Execute the command "crontab -e" to generate or edit your cron-file. Alternatively

use "crontab -l" for listing your cron jobs or "crontab -r" for deleting all cron

jobs.

 

One line in the cron file looks like this:

1 2 3 4 5 /etc/myScript arguments

 

The five numbers at the beginning of the line represent the following:

1: minutes (0-59)

2: Hours (0-23)

3: Day (0-31)

4: Month (0-12 or January, February, ... 0 and 12=December)

5: Day of the week(0-7 or Monday, Tuesday, Wednesday, ... 0 and 7=Sunday)

This enables you to exactly define when a script is supposed to be started.

 

Wait, there is more! You can make the file even more flexible like this:

*: applies every time

1-4: start if 1,2,3 or 4 matches

1-4/2 step-by-step, here: 1 and 3

1,5,6: enumeration

*/3: every third

1-4,10-15: enumeration and range combined

 

Moreover you can define what SHELL is to execute the commands and who you want to

send the results to (via e-mail):

SHELL=/bin/bash

MAILTO=me@localhost

 

A few more examples:

# every day at 0:05

5 0 * * * $HOME/bin/daily.job >> $HOME/tmp/out 2>&1

 

# every first day of the month at 14:15

15 14 1 * * $HOME/bin/monthly

 

# on weekdays at 22:00

0 22 * * 1-5 mail -s "It's 10pm" joe%Joe,%%Where are your kids?%

 

# every day 23 minutes after every even hour (0:23, 2:23, ...)

23 0-23/2 * * * $HOME/status.sh

 

# Sundays at 4:05

5 4 * * sun $HOME/backup.sh full

 

Weekdays and calender days do not exclude each other but are considered

separately. If either pattern matches the script will execute.

 

----

Link to comment
Share on other sites

Thanks for the above posts, however, I am still having problems...

 

Here is the weird thing.  I put in a test cron job with the following

 

30 * * * * cp index.php index2.php

 

and it worked perfectly!  Great right... WRONG!

 

so I put this in right after that

 

35 * * * * classes/testEmailScript.php and it DIDN'T work?!?!?!

 

WTH!!!!  Do you have to execute it or something?  Just weird...

 

thanks for any help you can provide.

Link to comment
Share on other sites

Did you try what I sent?

 

1and1 allows cron jobs of any amount of time, but they suggest them greater than 5 minutes to avoid server delays.

 

This is what you need to do BEFORE creating the cron job. Cron jobs run automatically, you do not need to run the file manually at any point (that is the point of cron jobs =) )

 

The first thing is to login to your server via SSH to create Crontabs.

---

 

 

The installation of entries in the crontab file is started with the "crontab" command.

 

There are various options coupled with this command.

Options Meaning

-l (list) shows the current contents of an appointment file

-d (delete) deletes an appointment file from the ./crontabs. directory.

-e (edit) publishes and edits the crontab file. This function is usually automatically started by the Editor Vi when called upon. As soon as Editor Vi is left, the processed crontab file is automatically installed.

-r (replace) replaces an appointment file in the ./crontabs. directory with the entrances.

 

With crontab -e you can start your entries. First enter one or two comment lines

that begin with the (#) symbol, and then the cron tab entry:

 

For e.g.

# A cron job every Monday at midnight 11.30 PM

30 23 * * 1 /homepages/xx/dxxxxxxxx/cgi-bin/members.cgi

 

After the file is stored, crontab will announce either implementation "ccrontab:

installing new crontab" or any command failure that may occur.

Should a failure occur, the cron tab will announce it with the following failure

announcement:

"errors in crontab file, can't install, do you want to retry the same edit?"

by entering "y" you can return to processing.

 

When everything is installed, you can show your entries by using the following

command:

crontab -l

 

Please Note: On shared hosting packages like

Business/Developer Linux/Professional Preview/Premier Professional Preview packages

it is advised to run the cron job every 5 minutes or above. Using a lower number will

queue up the jobs and this can potentially cause unnecessary load on the servers.

 

--

 

Link to comment
Share on other sites

FINALLY!

 

Figured it out!

 

Here we go

 

0,15,30,45 * * * * /usr/local/bin/php testEmailScript.php

 

1and1 needs that /usr/local/bin/php in front of the path.. don't know why but it is working FINALLY!

 

thanks for all your help folks.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.