Linux init scripts with php

As seen on http://tips4linux.com/create-a-startup-script-for-debian-and-ubuntu-systems/. Edit the following file:

sudo vim /etc/init.d/local.autostart

Add this php script

#!/usr/bin/php
<?php


// NOTE! Edit $path in the following line to a path 
$path ="/home/dennis/init_hello.log";
file_put_contents($path, "Hello World From init");

And:

sudo chmod +x /etc/init.d/local.autostart
sudo update-rc.d local.autostart defaults 80

That is it. You got a auto start script.

Reboot and check the file /home/dennis/init.hello.log (or what ever you called the file) and look it and get you "Hello World"


This page has been viewed 2568 times. First hit: 01-Nov-2015 00:22:29
Share email, Google+, Twitter, Facebook.
comments powered by Disqus
Table