php script behaves different as cron job

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Christoph

    #1

    php script behaves different as cron job

    Hi,

    I wrote a php script, which calls with the system-command the
    commandline tool "transcode" . transcode is a tool to convert audio and
    video files in different codecs.
    When I call the php-script in the commandline like this: php
    myScripct.php it works fine and transcode render my video files well.
    But when I run the php-script as a cron job like "5 * * * root php
    /path/myscript" the script behaves different. It starts the system
    call but it seams, that it doesn't wait until transcode finish its
    work. The file that transcode generate are all 0 KB.

    What can I do?

    Christoph Czeplak
  • Karthik

    #2
    Re: php script behaves different as cron job

    google@czeplak. de (Christoph) wrote in message news:<f9e85222. 0311110130.4493 41fe@posting.go ogle.com>...[color=blue]
    > Hi,
    >
    > I wrote a php script, which calls with the system-command the
    > commandline tool "transcode" . transcode is a tool to convert audio and
    > video files in different codecs.
    > When I call the php-script in the commandline like this: php
    > myScripct.php it works fine and transcode render my video files well.
    > But when I run the php-script as a cron job like "5 * * * root php
    > /path/myscript" the script behaves different. It starts the system
    > call but it seams, that it doesn't wait until transcode finish its
    > work. The file that transcode generate are all 0 KB.
    >
    > What can I do?
    >
    > Christoph Czeplak[/color]



    Why dont you try to run it using lynx. Thats what i do when i want to
    run it in a cron.

    for eg: 5 * * * * lynx -dump scriptname.php

    Try it this way.

    Karthik

    Comment

    • Terence

      #3
      Re: php script behaves different as cron job

      Christoph wrote:
      [color=blue]
      > Hi,
      >
      > I wrote a php script, which calls with the system-command the
      > commandline tool "transcode" . transcode is a tool to convert audio and
      > video files in different codecs.
      > When I call the php-script in the commandline like this: php
      > myScripct.php it works fine and transcode render my video files well.
      > But when I run the php-script as a cron job like "5 * * * root php
      > /path/myscript" the script behaves different. It starts the system
      > call but it seams, that it doesn't wait until transcode finish its
      > work. The file that transcode generate are all 0 KB.
      >
      > What can I do?
      >
      > Christoph Czeplak[/color]

      Sounds like the cron commands are running in the same process/thread. I
      don't know much about this sort of stuff but you may have to write some
      sort of wrapper which spawns different instances of transcoder (or your
      PHP script) in new threads or processors. Can do this in Java or C++ I
      guess.

      Try putting a & at the end of your /path/myscript command
      (shot in the dark).
      so...
      "5 * * * root php /path/myscript &"

      Comment

      Working...