Find the answer to your Linux question:
Results 1 to 3 of 3
I've created a crontab to run a php script (daemon) at boot. crontab -l: Code: (at)reboot /usr/bin/php-cgi /var/backbone/fork_sema.php 2>&1 > /dev/null (at)reboot export EDITOR="vi" When I run the command as ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Oct 2009
    Posts
    4

    [SOLVED] Crontab not working


    I've created a crontab to run a php script (daemon) at boot.

    crontab -l:
    Code:
    (at)reboot /usr/bin/php-cgi /var/backbone/fork_sema.php 2>&1 > /dev/null
    (at)reboot export EDITOR="vi"
    When I run the command as root it works. I've added "#!/usr/bin/php-cgi -q" to the beginning of the file. I've also tried to putting "root" before the command, which I've now removed. The command is executed at boot, but the script is not running.

    The second command doesn't work either.

    Any suggestions? Thanks..

  2. #2
    Linux Guru Lakshmipathi's Avatar
    Join Date
    Sep 2006
    Location
    3rd rock from sun - Often seen near moon
    Posts
    1,758
    (at)reboot export EDITOR="vi"
    Which distro are you using? Are you trying at command? .Check this link.
    A quick and simple guide to crontab usage - crontabrocks.org
    for crontab examples
    First they ignore you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
    -----
    FOSS India Award winning ext3fs Undelete tool www.giis.co.in. Online Linux Terminal http://www.webminal.org

  3. #3
    Just Joined!
    Join Date
    Oct 2009
    Posts
    4
    Problem found.

    Apparently cron runs before mysql. My php script quits because it is unable to connect to the db.

    Fix: Put a sleep before connection attempt.

    I also was able to make the default editor change permanent by editing ".bash_aliases".

    Thanks-

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •