0

I have a cron job that calculates the disk space on ServerA

I have a MySQL database on ServerB that stores the disk space values

ServerA in not allowed to access MySQL database on ServerB (Rules out direct MySQL Connect)

ServerA cannot open files on ServerB (Rules out include();)

ServerA and ServerB have no shell_exec() abilities

I've tried header("Location: http://ServerB.com/record.php?disk_space=$disk_space"); using a get method then the receiving file $_REQUEST the values but it only works when run through browser and not when run as a cron job.

I think there are no proper alternatives. But I'm happy with a peculiar or scruffy solution. Please put forward your ideas. TIA

michael_wu
16k5 gold badges66 silver badges77 bronze badges
asked May 14, 2013 at 22:03
2
  • curl, file_get_contents() or even wget from a cron job would all work fine Commented May 14, 2013 at 22:04
  • This boils down to a question of what network protocol you'd like to use. If the MySQL server also runs a web server, you can treat that side like a normal dynamic webpage and just hit the URL from the cron job (via PHP itself or wget, curl, etc). Depending on your setup you may want more security in this layer, in which case SSH or something similar might be a better choice. Do you have any restrictions/preferences in this regard? Commented May 14, 2013 at 22:07

2 Answers 2

2

You can hit external scripts directly through a number of HTTP libraries -- as well as file_get_contents().

See:

You could even use sockets to make the request:

Lots of options (more than included here). Easiest, if your needs are simple, is just file_get_contents.

answered May 14, 2013 at 22:07
Sign up to request clarification or add additional context in comments.

Comments

0

create a file with an extension of php and write your script with mysqli_connect, etc and handle what you want to do as if you go the this page on your browser yourself than run cron job of that file , that should do it.

answered May 14, 2013 at 22:56

1 Comment

Thank you for your answer but the cron file must be executed from a separate server from where the MySQL server is hosted and running mysqli_connect will not work from external servers.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.