Run the script file after 5 or 10 min after restarting the system

I have created a ruby script file that checks the connection present or not. For example checking port 22 is opened or not.

Firstly I tried with cron job as follows

@reboot find ${HOME}/my_app/check_conn.rb

But it is executing immediately after starting the system.

Now I have to run this script after 5 or 10 min.

How can I do this. Is there any other way for doing this.

Thanks in advance.


Solution 1:

Add sleep 600; to the beginning of your crontab command to make it wait for 600 seconds before proceeding to the next step.

Your new crontab command would look like

@reboot sleep 600; find ${HOME}/my_app/check_conn.rb

Solution 2:

Don't do it depending on time, but after establishing a network connection. The right place to do it is below:

/etc/network/if-up.d