OPNsense Forum

Archive => 18.1 Legacy Series => Topic started by: akenopnsense on August 23, 2018, 12:05:21 pm

Title: Shutdown opnsense at "x" hours
Post by: akenopnsense on August 23, 2018, 12:05:21 pm
Dear Sir/Madam

  am using OPNsense 18.1.6-i386 wherein am not able to find setting for enabling me to shut down opnsense at specific time,i.e. after office hours automatically.

   do guide me, if this is even possible.

Regs
Ken
Title: Re: Shutdown opnsense at "x" hours
Post by: marjohn56 on August 23, 2018, 02:36:44 pm
If you shut it down, how are you going to restart it?


You need to follow the instructions here to create a cron  job - that job will call the shutdown script you will also need to create. The will be a shell script to call the shutdown command.


http://kb.unixservertech.com/other/networking/opnsense/cron-jobs (http://kb.unixservertech.com/other/networking/opnsense/cron-jobs)
Title: Re: Shutdown opnsense at "x" hours
Post by: akenopnsense on August 24, 2018, 08:49:00 am
Office hours ends at 5:00 PM daily and shutting down is manual everyday. restart would be next day at 9:00 AM. so there is no restart needed.

can you suggest the script that will go for shut down at x hours daily or point me to some eg.
Title: Re: Shutdown opnsense at "x" hours
Post by: marjohn56 on August 24, 2018, 09:40:58 am
There already is one, the system shutdown script =  "/usr/local/etc/rc.halt".
So all you need to do is create the "actions_shutdown.conf" file, which should look like this:



Code: [Select]
[shutdown]
command:/usr/local/etc/rc.halt
parameters:
type:script
message:cron event shutting down
description:Shutdown System


Save the file to "/usr/local/opnsense/service/conf/actions.d" folder.


Now go to the console and issue the following command
# service configd restart


Now you can create your cron event. Should look like this:


(https://preview.ibb.co/hNptv9/Capture.png) (https://ibb.co/eX4hoU)


Obviously change the time to suit.  :)

Title: Re: Shutdown opnsense at "x" hours
Post by: akenopnsense on September 06, 2018, 01:34:50 pm
sorry for the late reply.. thanks a lot. it works and am really happy now