Crontab on MyCloud EX2

Hi,

I got a MyCloud EX2. Now I like to get some date periodly refreshed. For that I like to use a cronjob. But if I add somethin to the Cronjob it get deleted after some hours. What can I do against that?

Benjamin

1 Like

Welcome to the Community.

How have you tried so far in order to prevent the Cronjob from being deleted?

Thanks for your answer. What do you mean? I don’t know what you want to tell me.

Found a good working Workaround on this ■■■■ Device. I created a new User with adduser, then created a Crontab File for this user and this works great. Only the File Permissions are a little Problem. But with little bit Linux Skills this Problems are gone… :slight_smile:

a predictable and reliable way of refreshing content on the EX2 is required via crontab.  Here are a few linux suggestions if you don’t know the command line very well.   1) export EDITOR vi      sets your favorite editor for editing the crontab. I assume the additional user has already been created then you can add or edit the user’s crontab 2) crontab -u USERNAME -e    (edits the crontab)  3) crontab -u USERNAME -l   (lists the crontab for that user).

Everything is removed after reboot, even the new created user account.
Is there any way to fix it?

mapawd wrote:

Everything is removed after reboot, even the new created user account.
Is there any way to fix it?

User accounts created from EX2’s dashboard should be persistent.

And user accounts created directly in the shell (bypassing the dashboard) are not deleted. You can confirm by looking at /etc/passwd file after a reboot. Just those users’ home directories are deleted after reboot. In fact entire /home tree is deleted (as is the entire /etc tree). You can backup the user’s home directory in /usr/local/config/ - this folder is the persistent settings storage location. and after reboot, you’ll have to manually bring back the user’s home directory. But the space in this directory is quite limited (approx 11MB free), so don’t store too much stuff in that directory, or else you’ll quickly hit the capacity and run into unexpected issues.

Unless you are willing to void your warranty and have the skills to compile the firmware with modded startup script from the source code provided on WD’s site, you will have to rely on manual restore of the home directories.

I added my cronjobs to /usr/local/config/config.xml like this

<add_backup
<item id=“1”
<method 3</method
<1></1
<2>
</2
<3></3
<4>
</4
<5>*</5
<run usb_backup -a Filmy -c jobrun</run
</item
</add_backup

it persists even over restart

edit: I can’t insert the code here, there are missing > after each line

can you explain what’s the config.xml for and how often will it run the command?

That file is there by default, you just add there your jobs. How often it will run depends on how you set it.

i see…but how do you set it?

instead of <add_backup i add something i invent like <add_autodelete

instead of <run usb_backup -a Filmy -c jobrun</run i put < run 0 * * * * /opt/bin/find … </run something like this?

what exactly are you trying to do?

Finally i read better this post…

You probably will want to try this (at your own risk)… It’s just what I did and it works. Even after reboots.

Go to /usr/local/config and edit the config.xml file by adding an entry in the section of the XML.

  1. Add an entry to the crond/list. This basically list number of cron jobs to be added. See mine below, I added surveillance to the list. You must also alter the number of jobs in , but this looks like you have to enter the count - 1 instead. I don’t know why. But it would work.

Now i understand better seeing the layout of my config.xml i just don’t understand what does he meam saying “but this looks like you have to enter the count - 1 instead. I don’t know why. But it would work.”

I’m just trying to add a couple of cronjobs

I’ll take a look on that file when I’m home, but I don’t think I had done anything with count, I just added new entries

that sounds nice,
however i added a couple of entries and rebooted…the device wasn’t anymore accessible form the network…
I’ve performed the 40sec reset
firmware: 2.11.157

Maybe it’s because i added a couple of new entries other user the other users put an entry in the middle of the list…

i solved installing Transmission using it to launch a script adding crontab entries… but i still would like to know also the config.xml method better… that could be useful too

This is how my crond part of config.xml looks like

these 4 entries were added by me:
usb_backup -a Backup -c jobrun
usb_backup -a Filmy -c jobrun
usb_backup -a installers -c jobrun
usb_backup -a Serialy -c jobrun

https://www.dropbox.com/s/adsnymux2t3t9k0/config.xml?dl=0

Unfortunately after a certain time my job i created using the startup script of transmission got deleted from crontab i don’t know exactly when or why but i’d like to know more about the other cronjobs who may have caused this… any ideas?

Thanks for your config.xml…
is there any reason why you put your job in the middle of the list?
Let me try that

It doesn’t matter whether you put it in the middle or at the end etc., it automatically sorts on restart. Also remember that there are also other settings in config.xml, I put here only “crond” part of it. There’s where you should do the changes, don’t change other settings.

i tried again but my cloud ex2 fw: 2.11.157 do not boot properly anymore with a custom config.xml

I know this is a year-old thread, but adding some info from my experience. Editing the config.xml worked to add my custom job to crontab and survived a reboot without taking down my unit. I think there may be some critical guidance missing from this post. There are a few characters that are commonly used in terminal commands that conflict with xml characters, for example less than (<), greater than (>), and ampersand (&), among a few others. These characters must be ‘escaped’ in order to live inside the xml file without ‘corrupting’ it. Even this forum has problems with these characters as evidenced by the missing less-than (<) symbols in previous posts. You can do this manually if you like (and have experience with xml escaping), but it’s probably much simpler to run it through a function to escape it automatically (to prevent human error if nothing else). One such tool is here:
https://www.freeformatter.com/xml-escape.html
Just paste your command line in there and copy the result to then paste into the <run> element as described above.
Hopes this helps someone else.