Jump to content

Multiple crontabs edit


webent

Recommended Posts

Hi, I found this bit of a tutorial to create my cron jobs for a couple tasks that I need ran in the middle of the night...

 

So, I created two different .txt files, put them in the same directory and gave them the magical command to begin...

 

Problem is, when I decided that I couldn't wait until tomorrow morning to test out whether or not the cron jobs would work correctly, I went in and typed, "crontab -l myfile.txt", thinking I could edit the time in which it would run, hehehe, guess what, that didn't work, it only showed one file...

 

So, I started to immediately suspect that you aren't supposed to have multiple crontabs in the same directory, that in fact, they can all be entered on one .txt file and then given the magical "crontab /home/user/myfile.txt" command to begin...

 

So, if I'm on track and correct thus far, could someone tell me how to correctly enter in more than one cron task on one crontab, because the tutorial made it very clear that {Enter} is a very big deal... I Googled and Googled but nowhere did I see anything related to more than one cron task in a crontab...

 

Do I just hit {Enter} at the end of the last character of the cron task and immediately start the next cron task? Like this?

 

MAILTO=support@mydomain.com
0 1 * * * /home/mydomain/public_html/directory/module_control.php?do_it
MAILTO=support@mydomain.com
30 1 * * * /home/mydomain/public_html/directory/compliance-check.php?do_it

 

Oh yeah, one more thing, will the cron pick up that I have variables on the link, so that the task in the .php will start, it'll see $_GET['do_it']?... the reason being is that I run them manually also and I use that variable to begin the task...

 

Link to comment
Share on other sites

Ok, tried to do that, with it like that in the example and it wouldn't take it, I got this error...

 

"/home/mydomain/cronjobs/crons.txt":4: premature EOF
errors in crontab file, can't install.

Link to comment
Share on other sites

While you can define shell variables within your crontab, they are usually of little use to php. Can we see how your attempting to use this variable?

 

Also, you have not told cron what program should execute your scripts. It would seem to me you want them to be executed via Apache, therefore, you need to make a http request. wget can do this for you. eg;

 

30 1 * * * wget http://yoursite.com/compliance-check.php?do_it

 

If you wanted to execute your script directly you could tell cron to use php's command line interface eg;

 

30 1 * * * php /home/mydomain/public_html/directory/compliance-check.php?do_it

 

However, doing it that way there is no such variable as $_GET.

 

As for the question....

 

Do I just hit {Enter} at the end of the last character of the cron task and immediately start the next cron task? Like this?

 

Depends on what editor your using (but most likely yes). When you issue crontab -e it simply opens your default text editor as defined in the $EDITOR shell variable.

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.