iam@nas wrote: ↑Wed Mar 06, 2019 9:52 pm
You may want to initialize the variables '$filename' and '$currentdir'.
Sorry I have never written anything in this language.
I'm learning slowly...
I want this to run every day at midnight.
Please can you guide me in roughly the right direction now that I have tree running...
Step 1. I Write and debug a .sh file, E.G. DirectoryListing.Sh to create the daily HTML file in a directory that I can backup.
I'm after a full HTML list of every user file present on my NAS.
My Script so far is:
#!/bin/sh
####################################
#
# List all files NAS TS212-P
# Write these files to a time stamped HTML file.
#
####################################
# Create listing filename.
date_time_stamp=$(date +%d%m%Y_%H%M%S")
hostname=$(hostname -s)
filename="$hostname-$date_time_stamp.html"
tree --dirsfirst --du --nolinks -hnHCp . -o "$filename"
What does $currentdir do as you use it in your script?
Step 2. Make the file executable - I'll do this after I get the script working.
Step 3. Create a cronjob to carry this task out.
I try to navigate to:
/etc/config/crontab
But I get permission denied.
I am logged in as admin.
Is crontab -e and then adding an entry the way to go for this?
4. Manage the HTML files that will be created every day. I guess another scheduled job that deletes the files in the file listing directory if they are older than x days?