How can I start a program automatically?

Status
Not open for further replies.

ObiTobi

Patron
Joined
Jul 12, 2013
Messages
316
Hi,

I'm using software to sync my data between NAS and my Windows/OSX clients. How do I set it to start automatically after rebooting?
 

Chris Moore

Hall of Famer
Joined
May 2, 2015
Messages
10,080
Hi,

I'm using software to sync my data between NAS and my Windows/OSX clients. How do I set it to start automatically after rebooting?
You first need to tell what software you are using and where that software is running. The thing you have told us leaves too many things up to our imagination.

When I have done something like this before, I ran the backup utility as a scheduled task on the PC. That avoids all sorts of problems with having the backup run.
 
Last edited:

ObiTobi

Patron
Joined
Jul 12, 2013
Messages
316
I use Syncovery and for FreeBSD SyncoveryRS (Syncovery Remote Service).
The only one thing I need is how to create a Cron Job that will be startet only after reboot. The GUI does not allow
 

Chris Moore

Hall of Famer
Joined
May 2, 2015
Messages
10,080
I use Syncovery and for FreeBSD SyncoveryRS (Syncovery Remote Service).
The only one thing I need is how to create a Cron Job that will be startet only after reboot. The GUI does not allow
How is it possible to install the software on FreeNAS? It should be in a jail. You have not yet explained what you think you want.
If it is in a jail, the cron job of the jail is what needs to be configured.


Sent from my SAMSUNG-SGH-I537 using Tapatalk
 
Last edited:

ObiTobi

Patron
Joined
Jul 12, 2013
Messages
316
How is it possible to install the software on FreeNAS?

I don't think I know what you mean by that. You can copy file to where, in that case to /usr/local/sbin
And no, it's not and it won't be a jail.
What I need is a cron job that does run after reboot. Nothing else.
 

Chris Moore

Hall of Famer
Joined
May 2, 2015
Messages
10,080
I don't think I know what you mean by that. You can copy file to where, in that case to /usr/local/sbin
And no, it's not and it won't be a jail.
What I need is a cron job that does run after reboot. Nothing else.
Have you tried rebooting the system since you copied software onto it?
You may find that things that you add to FreeNAS don't survive a reboot. You are not supposed to be able to add software to FreeNAS other than adding a jail and putting the software in the jail. If you are not listening, figure it out on your own.
 

ObiTobi

Patron
Joined
Jul 12, 2013
Messages
316
If you are not listening, figure it out on your own.
Maybe I didn't understand you but so far you haven't even begun to answer my question. Well, I'm already listening.


So the question was not how the software comes on NAS but how I create a special cron job.
By the way - when I put the software into a jail it doesn't change the fact that I have to do a cron job - the same problem. And now?
 

garm

Wizard
Joined
Aug 19, 2017
Messages
1,556
Don’t expose your core system to these kinds of tools, use jails. It’s what they where built for. In the jail the link is valid. If you do it in core FreeNAS just use the GUI, but don’t. It’s opening yourself up to a world of hurt.
 

Jailer

Not strong, but bad
Joined
Sep 12, 2014
Messages
4,977
This can't work because FreeNAS is always regenerating crontab file after each reboot.
That's why you install it in a jail as suggested.
 

Chris Moore

Hall of Famer
Joined
May 2, 2015
Messages
10,080
This can't work because FreeNAS is always regenerating crontab file after each reboot.

But now I found a solution for me. /I will check it later if it really works in every situation as I want it to./
You really should not add an application to FreeNAS. I don't know what solution you have come up with, but it is doubtless a bad one.
 

ObiTobi

Patron
Joined
Jul 12, 2013
Messages
316
I'm sure you're right about the jails. Maybe I didn't understand everything about jails - e.g. why do I have to choose an IP address for each jail?
And how can I create something like jail-template that the syncovery manufacturer can always deliver without the end users having to do anything?
/I know for myself that my current solution is not optimal and not for everyone. /
 

Chris Moore

Hall of Famer
Joined
May 2, 2015
Messages
10,080
I'm sure you're right about the jails. Maybe I didn't understand everything about jails - e.g. why do I have to choose an IP address for each jail?
Each jail gets it's own IP address because it is a para-virtual machine that has it's own separate configuration where you can install a software package and create a cron job that will run more like it is in a standalone BSD install.
And how can I create something like jail-template that the syncovery manufacturer can always deliver without the end users having to do anything?
/I know for myself that my current solution is not optimal and not for everyone. /
Are you one of the developers of this application? I just wonder why you want to create a template to make it easy for other users to configure?
It can be done, but FreeNAS is in the process of moving from warden jails to iocage jails, so the way of going about it is the question.
@Jailer what do you say?
 

Jailer

Not strong, but bad
Joined
Sep 12, 2014
Messages
4,977
I'm sure you're right about the jails. Maybe I didn't understand everything about jails - e.g. why do I have to choose an IP address for each jail?
And how can I create something like jail-template that the syncovery manufacturer can always deliver without the end users having to do anything?
/I know for myself that my current solution is not optimal and not for everyone. /
Well the developers would have to port it to FeeBSD and get it added to the repository. That's something you'll have to take up with the Syncovery developers or maybe someone in their community.

As far as getting it to run via startup you'll likely have to create a startup script and call it when the jail starts. The link @garm posted will help get you going in the right direction or you can set up a cron task in the FreeNAS GUI to start it.
 

MrToddsFriends

Documentation Browser
Joined
Jan 12, 2015
Messages
1,338
I use Syncovery and for FreeBSD SyncoveryRS (Syncovery Remote Service).
The only one thing I need is how to create a Cron Job that will be startet only after reboot. The GUI does not allow

You can copy file to where, in that case to /usr/local/sbin
And no, it's not and it won't be a jail.
What I need is a cron job that does run after reboot. Nothing else.

If I didn't miss vital points of the discussion there were two points that got mixed up so far.

First, if the Syncovery software used for synchronization already is available as a self-contained or even statically linked FreeBSD executable which doesn't have to be installed via an installer but only copied to an arbitrary location, it's not necessary to go the jail route. In this case just copy the executable (or "binary") to a folder which survives FreeNAS updates.
/root/local/sbin or /home/<arbitrary_user>/local/sbin would be examples for such folders (would have to be created by a user with adequate permissions).

Second, there might be some mix-up regarding cron jobs and init scripts. Both can be configured using the FreeNAS GUI (at least as long as no stuff inside a jail is involved). Init scripts are used to schedule commands to run at system startup as opposed to cron jobs which run commands on a regular schedule.
http://doc.freenas.org/11/tasks.html#init-shutdown-scripts
http://doc.freenas.org/11/tasks.html#cron-jobs
 
Last edited:

Jailer

Not strong, but bad
Joined
Sep 12, 2014
Messages
4,977
as opposed to cron jobs which run commands on a regular schedule.
True but you can also make a crontab entry in a jail with @reboot /path/to/script and it will execute the script when the jail starts.
 
Status
Not open for further replies.
Top