Is there a way to use traditional commands to update a symlink when it's older than the original file?
I use a Seafile server (similar to Dropbox) to make certain files available to my students. So I shared a directory and created links to those files. Both Seafile and Dropbox don't care about links and copy the actual files to the server.
The problem is that if I update the actual file, the link timestamp doesn't change and the new version of the file is not uploaded to the server.
I tried the trivial test:
[ ./shared/the-symlink -ot ./actualfiles/pontedfile ] && touch -h ./shared/the-symlink
test dereferences the link and the timestamp of the file is compared to itself, what results false, of course.
Note also that the symlink must be newer than the linked file. I don't need it to be set to the same timestamp.
Is there a way to
test check the timestamp of the link instead of the pointed file?
Other solutions I'm trying to avoid:
- Copying the files instead of linking would work, but I'd have to consume too much disk space because the files are usually large;
touching all symlinks would also works, but all the files would be copyied to the server again and again; (not a problem: see edit below)
I'm willing a more elegant solution than converting the timestamps to string and comparing them by my own...
This thead is not a solution for me.
This is not an answer to the question, but it's a solution for my problem:
touch -h * updates all symlinks timestamps. Seafile recognizes the change and takes action. Fornunately, it re-checks now using the actual file timestamp and upload only the files that changed.
The solution using
stat -c "%Y". Thanks to steve.