7141 questions

8568 answers

13830 comments

10608 members

0 votes
75 views 2 comments
by
Hi,

Is there a way i can do an automatic check to see what devices are online on the network from the router? I can ping them manually but would like to automate the process. i have seen the user scripts but assume these can only be done on startup.

Regards,

Stephen

1 Answer

+1 vote
by

Hello,

You can achieve your desired automatic pinging to other network devices only using user scripts. But it is not true that they can be only run one time on startup. You can rerun your script using crontab functionality:

  • Log in to the router using SSH client;
  • Use command crontab -e;
  • Add additional line to crontab, for example: ***** /root/test.sh

In this example script named test.sh that is in the root directory will run every single minute.

Crontab syntax explanation:

# ┌───────────── minute (0 - 59)
# │ ┌───────────── hour (0 - 23)
# │ │ ┌───────────── day of the month (1 - 31)
# │ │ │ ┌───────────── month (1 - 12)
# │ │ │ │ ┌───────────── day of the week (0 - 6) (Sunday to Saturday;
# │ │ │ │ │                                   7 is also Sunday on some systems)
# │ │ │ │ │
# │ │ │ │ │
# * * * * * <command to execute>
by
Thanks,

So next questions are:

a: so i would need a seperate line in the script for each device i wanted to ping?

b. does it have to be done from the SSH client or could it just be uploaded via the web interface?

c. where would the results go? could i view them from the system log?

This is all a bit new so still getting my head around it.

Thanks,

Stephen
by
a. It depends on how you are going to write your own script. If one script will be able to ping every of your device then one crontab line will be enough. Crontab basically just runs your script from a specific folder in a set period of time.

b. It can be done using SSH or CLI interfaces only.

c. You can write a crontab line so that it will save the output to a file. I suggest using this tool to generate correct crontab syntax: https://crontab-generator.org/