0

I have a server that I've setup running PHP. This serves JSON files and is running fine.

I also have several scripts that reads data from an outside source, connects to my MySQL Database Server, and runs commands to save the data to the MySQL Server.

Currently I am using Bash Scripts that are executed via Cron. Each Bash Script calls a PHP file that is saved in my normal web directory.

All of this is working fine, but I am wondering if there is a better way to do the timed scripts? Is it possible / more effective to write a Bash script that does the same thing as my PHP scripts?

Or what about Python or Ruby? I have always been confused about if Python or Ruby are for making webpages, or for making scripts that execute on the server.

I will also say that it is convenient that I can update the PHP scripts via my text editor and the changes instantly take effect - as opposed to having to connect to the server and fight with that text editor.

Chris
  • 353
  • 1
  • 4
  • 10

1 Answers1

0

Though PHP started out as a web-oriented language and still has native support for that, these days PHP, Ruby, and Python are all general-purpose scripting languages that can be used for a variety of purposes, including, but hardly limited to, websites.

If you already have PHP scripts doing what you want them to do, there's little reason to rewrite them in another language. As Michael Hampton's comment suggested, it's probably possible to remove the Bash wrappers entirely, since PHP is more powerful and will probably run faster once loaded. Rewriting your PHP scripts in Bash is probably not practical, but it really depends on what they're doing.

depquid
  • 130
  • 1
  • 12
  • Thank you. I think the core of my question was if I was missing out by using PHP to write these scripts. I will look into removing the Bash wrapper. – Chris Mar 27 '13 at 17:57