Need assistance with Cron/scripts and Mounting issues

Status
Not open for further replies.

nick779

Contributor
Joined
Dec 17, 2014
Messages
189
Ive followed a few guides creating scripts, testing them, and copying them to /etc but for some reason when I run them through the GUI nothing happens.

I have 3 working scripts from this thread: upsstat.sh zpstat.sh and esmart.sh
All 3 work perfect from the command line if im in the /etc directory (just running a sh upsstat.sh), but none work if im in the / directory. Even doing a /etc/sh scriptname.sh
All have had a chmod +x run for execute permissions.
When I set them up in the freenas box through tasks, none of them will run. (as root)

Can someone assist?

Also, I was following the the how to with setting up SMART reporting VIA email, just for the instructions to copy everything to /etc so it persists through reboots. I can run a 'mount -wu /' fine but when im done and I want to set it back to read only I cant. I run a 'mount -r /' and I get a

[root@HomeNAS] /etc# mount -r /
mount: /: unknown special file or file system

Thoughts?
 

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
What version of FreeNAS you use?

Note that my scripts are in /root/ and in the cron task I use root for the user and my command is simply /root/send_smart_report.sh for example. Also don't forget to check the "enabled" checkbox at the bottom of the cron task settings ;)
 
Last edited:

nick779

Contributor
Joined
Dec 17, 2014
Messages
189
What version of FreeNAS you use ?

Note that my scripts are in /root/ and in the cron task I use root for the user and my command is simply /root/send_smart_report.sh for example. Also don't forget to check the "enabled" checkbox at the bottom of the cron task settings ;)
Im on FreeNAS-9.3-STABLE-201502070132
I somehow fixed the script issue. I changed all the jobs to /etc/scriptname.sh instead of /etc/sh scriptname.sh and everything started working all of a sudden.

My problem with mounting still stands though. / should be mounted as read only right?
 

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
Look at the first line in the scripts, it's a shebang and it's purpose is to tell the system which shell to use to execute the script. So there is no need to execute the script explicitly with a shell, plus when you do this you should use the right path: /bin/sh not /etc/sh.

Ok, the 9.3 use a ZPool for the system so it's not mounted read-only like the 9.2 or lower. You don't have to use mount at all. You should reboot to cancel any change you made with the mount command.
 

nick779

Contributor
Joined
Dec 17, 2014
Messages
189
I restarted immediately after finishing the scripts, I just wanted to make sure it was back to read only.

Im assuming it is back to that since I tried copying the scripts to /bin, did a cd .. and went back in and the scripts were gone.
 

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
You shouldn't put your custom scripts in /bin to begin with, but it should work anyway. Are you sure you have the required permissions ? cp should either, work, or fail with a message (like "permission denied" for example).

First things first: you use the web GUI shell or SSH?

Edit: I just searched to confirm that on the 9.3 the system isn't mounted read-only and it's confirmed https://forums.freenas.org/index.ph...on-read-only-file-systemmv.26584/#post-169054 whatever your problem is it's not related to the filesystem mount options.
 
Last edited:

nick779

Contributor
Joined
Dec 17, 2014
Messages
189
You shouldn't put your custom scripts in /bin to begin with, but it should work anyway. Are you sure you have the required permissions ? cp should either, work, or fail with a message (like "permission denied" for example).

First things first: you use the web GUI shell or SSH?

Edit: I just searched to confirm that on the 9.3 the system isn't mounted read-only and it's confirmed https://forums.freenas.org/index.ph...on-read-only-file-systemmv.26584/#post-169054 whatever your problem is it's not related to the filesystem mount options.

Generally I use the GUI, but when I do scripts, I find ssh to be much easier to work with.
It copied the files, but when I left that folder and went back in they were gone. Regardless, theyre still in the /etc folder and seem to be working fine. I was just following a how to from another post, thats why I put them into the /etc directory.

Good to know the boot drive isnt read only anymore though.
 

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
Ok, you're using which user to SSH?
 

nick779

Contributor
Joined
Dec 17, 2014
Messages
189

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
Hum... so it can't be a permission problem.

How you did the cp exactly (one character can make the difference)?

Just to be sure I tested right now to create a file and I copied it to /bin, then cd to some others folders, then cd back in /bin and no problem, the file was here.
 

nick779

Contributor
Joined
Dec 17, 2014
Messages
189
Hum... so it can't be a permission problem.

How you did the cp exactly (one character can make the difference)?

Just to be sure I tested right now to create a file and I copied it to /bin, then cd to some others folders, then cd back in /bin and no problem, the file was here.

I went into /bin and did a `cp /etc/esmart.sh .` The files do copy, but they disappeared
 

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
Waow, you've just blown my mind. I have no idea on what happened. Anyone has an idea?
 

nick779

Contributor
Joined
Dec 17, 2014
Messages
189
Waow, you've just blown my mind. I have no idea on what happened. Anyone has an idea?
weird right?

Edit: the chmod +x seems to have been removed too
 

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
Maybe I've one last idea: are you absolutely sure you cd to /bin and not to another folder before the cp?
 

nick779

Contributor
Joined
Dec 17, 2014
Messages
189
Maybe I've one last idea: are you absolutely sure you cd to /bin and not to another folder before the cp?

I should have clarified, this is in the /etc directory where the scripts are that had their permissions changed again
 

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
I talk about that:
I went into /bin and did a `cp /etc/esmart.sh .` The files do copy, but they disappeared

If you've cd to the wrong directory by inadvertence and then copied the file, when you "go back" to /bin you in fact go in /bin for the first time.

What permissions?
 

nick779

Contributor
Joined
Dec 17, 2014
Messages
189
I talk about that:


If you've cd to the wrong directory by inadvertence and then copied the file, when you "go back" to /bin you in fact go in /bin for the first time.

What permissions?

Sorry, that was a bit confusing. I initially copied them to /etc like the write up I read said to. I wanted to make them native (run anywhere) commands, so if memory serves I should just have to dump them into the /bin dir. I added execute permissions to both, tested and it worked.

I rebooted and the scripts went missing from /bin and the permissions were missing from the ones in /etc.

Today, I created a folder in root's home directory and copied the scripts there, added the permissions, rebooted, and everything seems to be good.
 

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
Ah you rebooted, this explain that.

In theory /bin is reserved for the system, you shouldn't put customs scripts here. In the case of FreeNAS it's more complicated because some of the directories/files are replaced at each reboot (they are copied from /conf/base for example) so the best thing is to let the system dirs/files alone and put your scripts in /mnt/your_pool or in the home directory (which is /root for the root account). The later has the benefit of offering a quick access to the scripts because it's the default directory when you SSH or use the web GUI terminal, and also you don't need to have the pool mounted (useful if the script is precisely doing something before the pool is mounted for example...) ;)
 

nick779

Contributor
Joined
Dec 17, 2014
Messages
189
Ah you rebooted, this explain that.

In theory /bin is reserved for the system, you shouldn't put customs scripts here. In the case of FreeNAS it's more complicated because some of the directories/files are replaced at each reboot (they are copied from /conf/base for example) so the best thing is to let the system dirs/files alone and put your scripts in /mnt/your_pool or in the home directory (which is /root for the root account). The later has the benefit of offering a quick access to the scripts because it's the default directory when you SSH or use the web GUI terminal, and also you don't need to have the pool mounted (useful if the script is precisely doing something before the pool is mounted for example...) ;)

I ended up going that route. After just having to start over from scratch Id like to keep it lean and efficient. All scripts stay in the root directory now.
 
Status
Not open for further replies.
Top