Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Linux, Apache, MySQL, PHP
  4. How to execute a URL in cron job at Linux Server

How to execute a URL in cron job at Linux Server

Scheduled Pinned Locked Moved Linux, Apache, MySQL, PHP
phpsysadminlinuxtutorialquestion
10 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Varun Sareen
    wrote on last edited by
    #1

    Dear Friends, I want to execute a redirect a URL in which i have to call a gateway server in order to send a sms. The Server on which i want to redirect a url is Linux based and the file code is on PHP. The particular php file is executed as a cron job. As a cron job runs in backgroud, we are not able to redirect (Response.redirect("url") not allowed) and also it runs at middle layer (not presentation layer); how one will be able to do the above task then? Thanks

    C 1 Reply Last reply
    0
    • V Varun Sareen

      Dear Friends, I want to execute a redirect a URL in which i have to call a gateway server in order to send a sms. The Server on which i want to redirect a url is Linux based and the file code is on PHP. The particular php file is executed as a cron job. As a cron job runs in backgroud, we are not able to redirect (Response.redirect("url") not allowed) and also it runs at middle layer (not presentation layer); how one will be able to do the above task then? Thanks

      C Offline
      C Offline
      cjoki
      wrote on last edited by
      #2

      I spoke with a co-worker on this and he said you would need a few things. One you need a cell card to tie into the cell network. What device you use should also include a software library from sending message via SMS. With that you should need a commandline parameter list or API reference to the software. From there you can code the php to build the message and all need variables needed to pass to the software. Hope that helps.

      V 1 Reply Last reply
      0
      • C cjoki

        I spoke with a co-worker on this and he said you would need a few things. One you need a cell card to tie into the cell network. What device you use should also include a software library from sending message via SMS. With that you should need a commandline parameter list or API reference to the software. From there you can code the php to build the message and all need variables needed to pass to the software. Hope that helps.

        V Offline
        V Offline
        Varun Sareen
        wrote on last edited by
        #3

        Dear Cjoki, I think you haven't understand the question. Well I am replying it again to make you clear that, I want to execute a url in php file which is executing in a cron job. The url after executing will be sending a sms to the specified number in the url. I hope you now understand the question and can give me a positive approach of solving it. Thanks Varun Sareen

        C 1 Reply Last reply
        0
        • V Varun Sareen

          Dear Cjoki, I think you haven't understand the question. Well I am replying it again to make you clear that, I want to execute a url in php file which is executing in a cron job. The url after executing will be sending a sms to the specified number in the url. I hope you now understand the question and can give me a positive approach of solving it. Thanks Varun Sareen

          C Offline
          C Offline
          cjoki
          wrote on last edited by
          #4

          From my reading of SMS on wikipedia it looks like that the SMS gateways need a user login for the connection. This may be why you are getting the message you are. I wonder if you have tested your connect to the gateway outside of the php script? can you connect to the gateway using another application and send a message? Here is the SMS info for your review. http://en.wikipedia.org/wiki/SMS[^] Maybe it will shed some light on your issue.

          V 1 Reply Last reply
          0
          • C cjoki

            From my reading of SMS on wikipedia it looks like that the SMS gateways need a user login for the connection. This may be why you are getting the message you are. I wonder if you have tested your connect to the gateway outside of the php script? can you connect to the gateway using another application and send a message? Here is the SMS info for your review. http://en.wikipedia.org/wiki/SMS[^] Maybe it will shed some light on your issue.

            V Offline
            V Offline
            Varun Sareen
            wrote on last edited by
            #5

            Dear Czoki, It's really great and so nice of you that you are showing so much of involvement into my problem but i guess you still not able to get me, I wonder where i am going wrong. Well let me try again.... My question is that how a URL can be executed in a cron job. The URL is actually calling the gateway server ( a third party client) with all the credentials required (I have checked it manually, I am able to send the sms from this gateway server by executing the php file (containing the URL) manually). But the problem is arising when I am executing the php script file from cron job, the url code is not getting executed and hence the sms is not being sent. I hope now you can understand where the problem is coming and eagerly waiting for a gud and positive reply. Thanks

            C 1 Reply Last reply
            0
            • V Varun Sareen

              Dear Czoki, It's really great and so nice of you that you are showing so much of involvement into my problem but i guess you still not able to get me, I wonder where i am going wrong. Well let me try again.... My question is that how a URL can be executed in a cron job. The URL is actually calling the gateway server ( a third party client) with all the credentials required (I have checked it manually, I am able to send the sms from this gateway server by executing the php file (containing the URL) manually). But the problem is arising when I am executing the php script file from cron job, the url code is not getting executed and hence the sms is not being sent. I hope now you can understand where the problem is coming and eagerly waiting for a gud and positive reply. Thanks

              C Offline
              C Offline
              cjoki
              wrote on last edited by
              #6

              OK Varum, You are having an issue with cron running the php successfully? You can manually run the php script with success? What does your commandline look like that runs the php script?

              V 1 Reply Last reply
              0
              • C cjoki

                OK Varum, You are having an issue with cron running the php successfully? You can manually run the php script with success? What does your commandline look like that runs the php script?

                V Offline
                V Offline
                Varun Sareen
                wrote on last edited by
                #7

                Hello Cjoki, There you go dear, I am happy that i made you understand my problem. Well, Yes I am having an issue in php script code but not in running the php script through cron job but in executing a URL in the php code while executing the php script file through cron job (although I am able to execute the URL while executing the php file by typing the location of php file in the address bar). In order to execute a URL in php script; I have to execute it in a iframe control but the particular iframe control code is not running when i execute the php file through cron job. :( The iframe code is as follows:

                (where "strURL" is the location at which my php file is present) Regards, Varun Sareen

                M 1 Reply Last reply
                0
                • V Varun Sareen

                  Hello Cjoki, There you go dear, I am happy that i made you understand my problem. Well, Yes I am having an issue in php script code but not in running the php script through cron job but in executing a URL in the php code while executing the php script file through cron job (although I am able to execute the URL while executing the php file by typing the location of php file in the address bar). In order to execute a URL in php script; I have to execute it in a iframe control but the particular iframe control code is not running when i execute the php file through cron job. :( The iframe code is as follows:

                  (where "strURL" is the location at which my php file is present) Regards, Varun Sareen

                  M Offline
                  M Offline
                  markkuk
                  wrote on last edited by
                  #8

                  iframes aren't PHP code, they are HTML elements that are interpreted by web browsers. You can't run a mixed HTML/PHP page using the stand-alone PHP interpreter. You must figure out what the HTML code emitted by the PHP script actually does when interpreted by a browser, then duplicate that action by a different script (possibly in another programming language).

                  C 1 Reply Last reply
                  0
                  • M markkuk

                    iframes aren't PHP code, they are HTML elements that are interpreted by web browsers. You can't run a mixed HTML/PHP page using the stand-alone PHP interpreter. You must figure out what the HTML code emitted by the PHP script actually does when interpreted by a browser, then duplicate that action by a different script (possibly in another programming language).

                    C Offline
                    C Offline
                    cjoki
                    wrote on last edited by
                    #9

                    markkuk is right here. Please understand that php runs on the server and your iFrame runs in the clients browser. I am not even sure how cron works into this as I thought you were making a shell program, not one that runs in a browser. Beside that you also have issues with permissions that require attention and cross site scripting issues to boot. I suspect your code logic is way off mark Varun ...sorry.

                    modified on Friday, October 1, 2010 10:27 AM

                    V 1 Reply Last reply
                    0
                    • C cjoki

                      markkuk is right here. Please understand that php runs on the server and your iFrame runs in the clients browser. I am not even sure how cron works into this as I thought you were making a shell program, not one that runs in a browser. Beside that you also have issues with permissions that require attention and cross site scripting issues to boot. I suspect your code logic is way off mark Varun ...sorry.

                      modified on Friday, October 1, 2010 10:27 AM

                      V Offline
                      V Offline
                      Varun Sareen
                      wrote on last edited by
                      #10

                      Dear Cjoki, I just want to know the solution from you, friends and i very well understand that i can't run a html control code in cron job. I was just asking that the thing wasn't working what's the other way out. I wish i could have mentioned that: **"I know why

                      is not working in cron job otherwise i may be receiving some solution rather than such harsh comments from you friends.** . It's sad... :( Well.... Thanks Varun Sareen

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups