Cron not working

Status
Not open for further replies.

indivision

Guru
Joined
Jan 4, 2013
Messages
806
I am trying to set up a cron task that restarts a jail service every 6 hours. Here is the command:

Code:
jexec <jail_name> service <service_name> restart


When I run this code in the shell as root or click "Run Now" in the View Cron Jobs section, it works.

However, it doesn't appear to run properly on its own. The schedule looks to be ok because output is generated by the task right on schedule as expected. But, when I look at the service at those times, it is not affected.

I believe I have the settings right so that it sends output when there is an error. And I am getting output. But, its not informative error information. Here is what the output emails are:

Code:
usage: chown [-fhvx] [-R [-H | -L | -P]] owner[:group] file ...
	   chown [-fhvx] [-R [-H | -L | -P]] :group file ...


Any ideas about what is happening here and how to get this Cron task to run properly?

Thank you.
 

rvassar

Guru
Joined
May 2, 2018
Messages
972
That's the useage output for the "chown" command. So something is executing "chown" with options that it can't parse.
 

indivision

Guru
Joined
Jan 4, 2013
Messages
806
That's the useage output for the "chown" command. So something is executing "chown" with options that it can't parse.

Thank you. The subject line of the email includes my cron task and I am receiving it on the cron task schedule every 6 hours.

It seems odd to me that chown would become involved with the command I have put in. But, maybe I am missing some factor here? Can someone confirm that is ok? Almost seems suspect...

I am running the cron task as root. Is that problematic somehow?
 

Chris Moore

Hall of Famer
Joined
May 2, 2015
Messages
10,080
I am running the cron task as root. Is that problematic somehow?
Are you trying to edit cron files or are you setting this up in the GUI?
 

indivision

Guru
Joined
Jan 4, 2013
Messages
806
Are you trying to edit cron files or are you setting this up in the GUI?

This is all set up in the GUI. I haven't touched the crontab directly.
 

rvassar

Guru
Joined
May 2, 2018
Messages
972
I have limited knowledge of how FreeNAS implements cron jobs via the GUI. Is this a GUI derived cron job, or something you've set up via ssh? It may be wrapping the "jexec" line in some kind of wrapper script, that it emits as a file at runtime, and then expects to "chown" to some user ID before executing. If that UID doesn't exist, or is misconfigured, chown would likely throw an error like that. But I'm kind of speculating here, and don't feel comfortable taking it any further than that. My expertise is traditional Unix/Linux, I'm still learning FreeNAS.
 

rvassar

Guru
Joined
May 2, 2018
Messages
972

indivision

Guru
Joined
Jan 4, 2013
Messages
806
I have limited knowledge of how FreeNAS implements cron jobs via the GUI. Is this a GUI derived cron job, or something you've set up via ssh? It may be wrapping the "jexec" line in some kind of wrapper script, that it emits as a file at runtime, and then expects to "chown" to some user ID before executing. If that UID doesn't exist, or is misconfigured, chown would likely throw an error like that. But I'm kind of speculating here, and don't feel comfortable taking it any further than that. My expertise is traditional Unix/Linux, I'm still learning FreeNAS.

It is a GUI derived cron job. I haven't touched the crontab file directly.

What UID does the jail run under?

root which is UID 0

I do seem to remember that FreeNAS does have a certain approach to the root account for security. So, maybe that is the issue?
 

rvassar

Guru
Joined
May 2, 2018
Messages
972
Inserting a root cronjob would be a security issue, so... It may be limited. But again, I'm at the end of my FreeNAS knowledge here. Under a traditional Unix/Linux system my next step would be to implement a regular cron job or even a script. By script I mean something that runs the command and then sleeps for 6 hours in an endless loop.
 

indivision

Guru
Joined
Jan 4, 2013
Messages
806
Inserting a root cronjob would be a security issue, so... It may be limited. But again, I'm at the end of my FreeNAS knowledge here. Under a traditional Unix/Linux system my next step would be to implement a regular cron job or even a script. By script I mean something that runs the command and then sleeps for 6 hours in an endless loop.

Ok. I would prefer to use the GUI cron setup. Should be a way to make it work.

Any ideas on what steps I would need to take to run the same task the same way but with a user with proper permissions? I'm a little thrown off on how that would work running cron on a service within a jail. Would I need to use a user that is also set up in the jail? Can I skip the top level permissions and use a user from the jail?
 
Status
Not open for further replies.
Top