Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8254729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:17:36+00:00 2026-06-08T01:17:36+00:00

I’m trying to make a push notification work on my debian vps (apace2, mysql).

  • 0

I’m trying to make a push notification work on my debian vps (apace2, mysql).

I use a php script from this tutorial (http://www.raywenderlich.com/3525/apple-push-notification-services-tutorial-part-2).

Basically, the script is put in an infintive loop, that check a mysql table for new records every couple of seconds. The tutorial says it should be run as a background process.

// This script should be run as a background process on the server. It checks
// every few seconds for new messages in the database table push_queue and 
// sends them to the Apple Push Notification Service.
//
// Usage: php push.php development &

So I have four questions.

  1. How do I start the script from the terminal? What should I type? The script location on the server is:

    /var/www/development_folder/scripts/push2/push.php

  2. How can I kill it if I need to (without having to restart apace)?

  3. Since the push notification is essential, I need a way to check if the script is running.
    The code (from the tutorial) calls a function is something goes wrong:

    function fatalError($message)
    {
     writeToLog('Exiting with fatal error: ' . $message);
     exit;
    }
    

Maybe I can put something in there to restart the script? But It would also be nice to have a cron job or something that check every 5 minute or so if the script is running, and start it if it doens’t.

4 – Can I make the script automatically start after a apace or mysql restart? If the server crash or something else happens that need a apace restart?

Thanks a lot in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T01:17:39+00:00Added an answer on June 8, 2026 at 1:17 am
    1. You could run the script with the following command:

      nohup php /var/www/development_folder/scripts/push2/push.php > /dev/null &
      

      The nohup means that that the command should not quit (it ignores hangup signal) when you e.g. close your terminal window. If you don’t care about this you could just start the process with “php /var/www/development_folder/scripts/push2/push.php &” instead. PS! nohup logs the script output to a file called nohup.out as default, if you do not want this, just add > /dev/null as I’ve done here. The & at the end means that the proccess will run in the background.
      I would only recommend starting the push script like this while you test your code. The script should be run as a daemon at system-startup instead (see 4.) if it’s important that it runs all the time.

    2. Just type

      ps ax | grep push.php
      

      and you will get the processid (pid). It will look something like this:

      4530 pts/3    S      0:00 php /var/www/development_folder/scripts/push2/push.php
      

      The pid is the first number you’ll see. You can then run the following command to kill the script:

      kill -9 4530
      

      If you run ps ax | grep push.php again the process should now be gone.

    3. I would recommend that you make a cronjob that checks if the php-script is running, and if not, starts it. You could do this with ps ax and grep checks inside your shell script. Something like this should do it:

      if ! ps ax | grep -v grep | grep 'push.php' > /dev/null
      then
        nohup php /var/www/development_folder/scripts/push2/push.php > /dev/null &
      else
        echo "push-script is already running"
      fi
      
    4. If you want the script to start up after booting up the system you could make a file in /etc/init.d (e.g. /etc.init.d/mypushscript with something like this inside:

      php /var/www/development_folder/scripts/push2/push.php
      

      (You should probably have alot more in this file)

      You would also need to run the following commands:

      chmod +x /etc/init.d/mypushscript
      update-rc.d mypushscript defaults
      

      to make the script start at boot-time. I have not tested this so please do more research before making your own init script!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to understand how to use SyndicationItem to display feed which is
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm trying to create an if statement in PHP that prevents a single post
Basically, what I'm trying to create is a page of div tags, each has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.