1

I would like to real-hand experienced answer on this. Which one is faster? Writing a Shell Script or PHP script? This script be will setup in cron.

Here is the brief idea of what I am trying to accomplish.

We get a lot of PGP encrypted files from clients. We download them to our local server, decrypt them and move them to different location for further processing.

There could be around 20-25 files a day to do and the number goes up gradually.

We have written both PHP script and Shell script to do this, for testing purposes. But we are not sure which is going to faster and advantageous.

Has anyone tried? Any inputs?

Thanks much!

9
  • 5
    Well, if you've already written both, why not benchmark each and you'll have a solid answer? Commented Jan 27, 2012 at 17:38
  • Faster? That depends on how you wrote each script. More reliable? Again- that depends on how you wrote the scripts. The only language/environment specific advantage I immediately see is that shell scrips are not tied to a web server. No timeout set, no relying on the Apache/IIS service to be up and running. In terms of speed, why dont you time each script to see if there is a major speed advantage? Commented Jan 27, 2012 at 17:39
  • @Kevin Are your PHP CLI scripts "tied to a web server"? Commented Jan 27, 2012 at 17:40
  • There are many variables: Your skill with each method, hardware performance, server load, and the target files will all work together to determine which method is more performant. As indicated above, benchmarking is the best way to find a useful answer. Commented Jan 27, 2012 at 17:41
  • 1
    PHP does not require a web server if you aren't serving web pages. Commented Jan 27, 2012 at 17:41

2 Answers 2

3

As indicated in the comments, you ought to just benchmark.

The overhead associated with the script will certainly be insignificant compared to the time spent in the decryption phase. (Cryptography is a notoriously computationally expensive process, especially dual-key crypto.)

Also, 20-25 requests, even 1000 requests, is nothing on a modern machine, unless we are talking about decrypting gigantic files (in which case, again, the crypto step will swamp any optimizations in the wrapper script). Asking this question and benchmarking are probably more time consuming that any overhead you will encounter.

(As an aside, I really hope that you are doing the decryption on a back-end machine not directly facing the public. Guard your key!)

Sign up to request clarification or add additional context in comments.

1 Comment

@Cornad Shults: Yes, we are doing it in the back-office system. Not the public facing. Bench-marking is going to take time. So I was looking for if someone has already tried it. And I believe, people who work with these kinds of scrips would usually can tell this quickly.
1

Both use an interpreter to execute your tasks. Depending on which OS you are using, their engines could have been both written in C++.

I would use PHP. Because it has more modules you can addon.

Say do your PGP encryption then you want to update a mySQL DB, Send an email, post to facebook, send a tweet out that your task is complete.

Edit - PHP doesn't require awebserv. I'm referring to the command line execution of php and shell script. PHP Command line help - http://php.net/manual/en/features.commandline.php

Comments

Your Answer

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.