Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Cron Simulator


Jack_mcs

Recommended Posts

This is the support thread for the Cron Simulator contribution. Cron is a program supplied by the host that allows a script to be ran at a preset time. Many osCommerce contributions make use of Cron but not all hosts offer it so those contributions can't be used to their fullest potential on such servers. The purpose of this contribution is to simulate a Cron job. Code is added to the index page of your admin and when it is loaded, the enabled jobs are checked and ran, if it is their time to be ran. This isn't as accurate as a real Cron job but it will run the script automatically, which is what is needed. This contribution is compatible with all versions of osCommerce.

Edited by Jack_mcs

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

  • Replies 50
  • Created
  • Last Reply

Top Posters In This Topic

This is the support thread for the Cron Simulator contribution. Cron is a program supplied by the host that allows a script to be ran at a preset time. Many osCommerce contributions make use of Cron but not all hosts offer it so those contributions can't be used to their fullest potential on such servers. The purpose of this contribution is to simulate a Cron job. Code is added to the index page of your admin and when it is loaded, the enabled jobs are checked and ran, if it is their time to be ran. This isn't as accurate as a real Cron job but it will run the script automatically, which is what is needed. This contribution is compatible with all versions of osCommerce.

 

 

Hello, very handy but can you please provide a basic help file on how to use your modification? As after I enter a script name, script location/filename and time it is not saving.

 

I just mean a basic example of what to put in each field.

 

Kind regards

Chris

Link to comment
Share on other sites

Hello, very handy but can you please provide a basic help file on how to use your modification? As after I enter a script name, script location/filename and time it is not saving.

 

I just mean a basic example of what to put in each field.

- Run - if checked, run the script

- Script Name - some arbitrary name that allows you to identify the script

- File Name - name of the script to be ran, like googlefeeder.php

- Time To Run - the time the script should be ran (only happens if index.php is visited so may not be accurate)

- Frequency - should it be ran daily, weekly or monthly?

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

- Run - if checked, run the script

- Script Name - some arbitrary name that allows you to identify the script

- File Name - name of the script to be ran, like googlefeeder.php

- Time To Run - the time the script should be ran (only happens if index.php is visited so may not be accurate)

- Frequency - should it be ran daily, weekly or monthly?

 

Ok thanks, Im thinking I might have some kind of issue then as I entered in the fields:

 

google base feed | googlefeeder.php(variations of path too) | 12 | weekly |

 

I click update and its not saved.

 

Im thinking maybe "tims safer database input mod" might have to be removed, not sure!

Link to comment
Share on other sites

Ok thanks, Im thinking I might have some kind of issue then as I entered in the fields:

 

google base feed | googlefeeder.php(variations of path too) | 12 | weekly |

 

I click update and its not saved.

 

Im thinking maybe "tims safer database input mod" might have to be removed, not sure!

I just tried entering

 

test | admin/test.php | 12 | weekly

 

and it saved correctly. The time (12) needs to be in military time (1200) but otherwise I don't see a problem. Are you sure the new entry isn't in the dropdown list?

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

I did as you said and it does not work, its not in the database as I checked in phpmyadmin also.

Hmm, I don't have an answer for you then. The code that adds the entries in the admin is just standard code used in many of my contributions. There must be something in your shop or on the server that is preventing it from working but I've no way to isolate that in a thread like this. If you are able to set up a clean shop, I suggest installing it into it to isolate the problem.

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

Yeah its really weird, It just refuses to save on a rc2a shop. The update button seems to react just like a refresh browser page button.

 

I removed the modifications added by tims safer database input method (installation file is wrong anyway)... same thing!

Link to comment
Share on other sites

Yeah its really weird, It just refuses to save on a rc2a shop. The update button seems to react just like a refresh browser page button.

 

I removed the modifications added by tims safer database input method (installation file is wrong anyway)... same thing!

 

Jack I'm having the same problem with this. When I check the database I can't help but notice that there is no index for that table. I don't know if one is needed or not but I wonder if that is preventing the data from being saved?

 

Dan

Link to comment
Share on other sites

Jack I'm having the same problem with this. When I check the database I can't help but notice that there is no index for that table. I don't know if one is needed or not but I wonder if that is preventing the data from being saved?

No, an index, or lack of one, shouldn't make it fail. It is possible that something is wrong in the code but it works fine in my test shop and on the site I created it for. What versions of php and mysql are you using? Maybe that has something to do with it.

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

No, an index, or lack of one, shouldn't make it fail. It is possible that something is wrong in the code but it works fine in my test shop and on the site I created it for. What versions of php and mysql are you using? Maybe that has something to do with it.

Lets see...MySQL 5.0.77 and PHP 5.2.10...dan

Link to comment
Share on other sites

The versions should be OK. Please try this. In admin/cron_simulator.php, find

  if (tep_not_null($action))   { 

     if (isset($_POST['update_cron_x'])) { 

and change it to

  ?> <pre> <?php
 print_r($_POST);
 ?> </pre> <?php
 if (tep_not_null($action))   { 
 echo 'action found<br>';
     if (isset($_POST['update_cron_x'])) { 
     echo 'update pressed<br>';

Try updating and post the displayed results here.

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

The versions should be OK. Please try this. In admin/cron_simulator.php, find

  if (tep_not_null($action))   { 

     if (isset($_POST['update_cron_x'])) { 

and change it to

  ?> <pre> <?php
 print_r($_POST);
 ?> </pre> <?php
 if (tep_not_null($action))   { 
 echo 'action found<br>';
     if (isset($_POST['update_cron_x'])) { 
     echo 'update pressed<br>';

Try updating and post the displayed results here.

 

I get this following Jack...

 

Array

(

[action] => process

[enabled_in] => on

[script_name_in] => AS_SiteMap

[file_name_in] => /googlesitemap/index.php

[time_to_run_in] => 1259

[frequency_in] => Daily

[scripts] => Select a Con Job

[update_cron_x] => 41

[update_cron_y] => 11

)

 

Dan

Link to comment
Share on other sites

OK. Remove those changes and replace this line

if (tep_not_null($action))   { 

with

  if (isset($_POST['action']) && $_POST['action'] == 'process') {

 

This is what happens when they let me out of the home around the holidays. :)

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

OK. Remove those changes and replace this line

if (tep_not_null($action))   { 

with

  if (isset($_POST['action']) && $_POST['action'] == 'process') {

 

This is what happens when they let me out of the home around the holidays. :)

That did it Jack...it is now saving the cron job...the problem I'm now having is that it's not finding the file to be executed. I'm trying to set up a cron for your Google Site Map but when I enter either googlesitemap/index.php or /googlesitemap/index.php it can't find the file....I can execute it from the url command line but the cron module says that it can't find the file....does the file name need to be specified in any special way?

 

Dan

Link to comment
Share on other sites

That did it Jack...it is now saving the cron job...the problem I'm now having is that it's not finding the file to be executed. I'm trying to set up a cron for your Google Site Map but when I enter either googlesitemap/index.php or /googlesitemap/index.php it can't find the file....I can execute it from the url command line but the cron module says that it can't find the file....does the file name need to be specified in any special way?

 

Dan

You have to enter in the full path, like /home/username/public_html/script_name.php. Also, if the path is too long, which it probably will be, you will need to alter the size of the field in the database with this command

ALTER TABLE `cron_simulator` CHANGE `file_name` `file_name` VARCHAR( 256 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL ;

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

You have to enter in the full path, like /home/username/public_html/script_name.php. Also, if the path is too long, which it probably will be, you will need to alter the size of the field in the database with this command

ALTER TABLE `cron_simulator` CHANGE `file_name` `file_name` VARCHAR( 256 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL ;

That sorted that Jack but now I seem to be running into functions that have already been declared...got this message when it tried to run the googlesitemap/index.php cron job....

 

Fatal error: Cannot redeclare tep_not_null() (previously declared in /xxxx/xxxxxxxxx/xxxxx/xxxxx/xxxxx/domain.com/xxxxx/admin/includes/functions/general.php:284) in /xxxx/xxxxxxxxx/xxxxx/xxxxx/xxxxx/domain.com/googlesitemap/index.php on line 72

 

Dan

Link to comment
Share on other sites

That sorted that Jack but now I seem to be running into functions that have already been declared...got this message when it tried to run the googlesitemap/index.php cron job....

 

Fatal error: Cannot redeclare tep_not_null() (previously declared in /xxxx/xxxxxxxxx/xxxxx/xxxxx/xxxxx/domain.com/xxxxx/admin/includes/functions/general.php:284) in /xxxx/xxxxxxxxx/xxxxx/xxxxx/xxxxx/domain.com/googlesitemap/index.php on line 72

 

Dan

Jack would you happen to know if this is a problem on my end or if something isn't quite right with the cron simulator?

 

Dan

Link to comment
Share on other sites

Jack would you happen to know if this is a problem on my end or if something isn't quite right with the cron simulator?

 

Dan

I'm sorry. I somehow missed your previous post. That is happening because the function tep_not_null has already been declared in admin and it can't be declared again. I don't know if there is a simple fix for that. You could add the code that you add to the admin/index.php file to the includes/footer.php (the other changes would be needed on the shop sitde too) but that would cause a delay whenever the script was ran and it would have to be edited to hide the output so that is not a good solution. I'll have to think on this but short of editing the googlesitemap file, I can't think of a good way around it.

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

I'm sorry. I somehow missed your previous post. That is happening because the function tep_not_null has already been declared in admin and it can't be declared again. I don't know if there is a simple fix for that. You could add the code that you add to the admin/index.php file to the includes/footer.php (the other changes would be needed on the shop sitde too) but that would cause a delay whenever the script was ran and it would have to be edited to hide the output so that is not a good solution. I'll have to think on this but short of editing the googlesitemap file, I can't think of a good way around it.

This is probably a dumb question Jack and if so, please forgive me but if it's already declared in admin/index.php does it need to be declared again in cron simulator or could we just delete the declaration of that function in the cron simulator? If not maybe we just need to rename it?

 

Dan

Link to comment
Share on other sites

This is probably a dumb question Jack and if so, please forgive me but if it's already declared in admin/index.php does it need to be declared again in cron simulator or could we just delete the declaration of that function in the cron simulator? If not maybe we just need to rename it?

It isn't being loaded by this contribution. When Cron Simulator is ran in admin. it loads in the application_top file, as any script in admin does. But when it tries to execute a scrit on the shop side, the shops side functions get reloaded by that script, causing the duplicate problem. The parts of the code causing the problem could be re-coded so it doesn't happen but that opens up big problem since any script ran that way would need to be rewritten and that doesn't make for a very usable contribution. The only way I can see around it without disrupting everything else is to rewrite the Cron Simulator script to run as a standalone script. But that removes the automatic process of running it so you might as well just run the scripts themselves manually. So as it stands now, scripts made to run from admin should work. Those made to run on the shop side may fail, depending upon how they are coded. I'll play around with it and post if I find a sensible solution.

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

It isn't being loaded by this contribution. When Cron Simulator is ran in admin. it loads in the application_top file, as any script in admin does. But when it tries to execute a scrit on the shop side, the shops side functions get reloaded by that script, causing the duplicate problem. The parts of the code causing the problem could be re-coded so it doesn't happen but that opens up big problem since any script ran that way would need to be rewritten and that doesn't make for a very usable contribution. The only way I can see around it without disrupting everything else is to rewrite the Cron Simulator script to run as a standalone script. But that removes the automatic process of running it so you might as well just run the scripts themselves manually. So as it stands now, scripts made to run from admin should work. Those made to run on the shop side may fail, depending upon how they are coded. I'll play around with it and post if I find a sensible solution.

 

I got it...thanks for the explanation Jack.

 

Dan

Link to comment
Share on other sites

  • 7 months later...

hi jack,

 

i need a cronjob in this format /mailhive.php?xyz=run

 

to run a cronjob for mailbeez ( http://www.mailbeez.com )

is there a posibility to do that with cronjob simulator?

i get an error "A valid file name is required" if i try to

 

an where can i delete cronjob entries? in the database i know

but is there a posibility to do directly from cronjob simulator?

 

:(

:(

 

greets

 

andy

post-263171-0-49135600-1314694894_thumb.jpg

Edited by trentano
Link to comment
Share on other sites

  • 1 month later...

Join the conversation

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

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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...