Startup script for a script

Hopefully this is descriptive enough, I have a script that runs a remote SSH command on another box, but I need it to run from a separate FreeBSD machine on boot. I've created and tested the script and it runs fine under manual execution, I just need a way to make it run automatic, preferably once the machine is fully booted (It's a NAS4Free machine)

I've looked into rc.d scripts and unfortunately they seem to cater more towards daemons and such, my attempts to adapt a script to my needs have not worked out well.

I was wondering what the easiest approach would be?

Thanks for any advice.
 
An alternate approach would be to run this using your user's crontab(5) file. An @reboot keyword would likely be appropriate and you wouldn't have to worry about making rc.d scripts that not every user needs to run or providing access to an SSH key to everybody on the system.

If you do go the rc.d route, the biggest thing to keep in mind is that the script started at boot or with the service(8) command set a restricted environment. This means if you are using an SSH key in /root/.ssh or program outside of PATH things would be unpredictable. As long as you keep that in mind I don't think using the rc.d infrastructure would cause any problem.
See service(8):
Code:
ENVIRONMENT
     When used to run rc.d scripts the service command sets HOME to / and PATH
     to /sbin:/bin:/usr/sbin:/usr/bin which is how they are set in /etc/rc at
     boot time.
 
Back
Top