How to run a Bash script or any file in background process with a initscript?

Hello,

I want to run a program in background process like mysqld or dnsmasq whome are in the folder: /etc/init.d

I know the cron jobs and the Scheduled tasks panel and I don't want to use them.

My purpose is to put a Bash script or any file in this folder in order to hope to run them in background process and connect MySQL server for sending data remotely in local area network and wide area network.

Do you think that it's allowed to do this?

Kind regards,

/mnt/sda1/updatesql.sh  &

Run it at background

nano /etc/rc.local
...
#echo 0 > /proc/sys/kernel/printk
/mnt/sda1/updatesql.sh  &
exit 0

Run it at reboot ( auto start).

This commands runs only at the start-up of my Yun and not permantly.

What a pity!

It does run in background process for Ubuntu 14.04 or others Linux distributions.

I think I'm going to use a cron job to do this.

Thanks you for your reply.

Kind regards,

jay97430:
This commands runs only at the start-up of my Yun and not permantly.

What a pity!

By putting that command in rc.local, yes, it will run every time the Yun starts. It is a permanent change, and will run it every time.

I'm not sure what you mean by "not permanently"? Are you saying that the script stops and does not keep running? If so, then you must make sure that it contains a loop so that it keeps running. Or, if you have an infinite loop, it could be stopping because of an error. In that case, you need to find what is causing it to stop and fix it. You should also probably have some exception handling to catch errors as they happen and not let the script stop.

If you can't manually start the script and have it keep running all the time, then adding it to rc.local isn't going to magically fix it.