I use a script for this which I creatively named start_at_exit.sh. It's takes 2 arguments the first is the name of the running process and the second is the command you wish to run when the running process had finished.
It's basically a while loop which checks the first argument against pgrep until no process is found. The loop then exits and the new command is executed.
I mostly use it to power off my machine during the weekend after a bunch of long computations have finished.
I think the main problem here is that cron is probably not running /bin/bash but /bin/sh. On some systems this might not be a problem since /bin/sh points to /bin/bash.
Since you are running a Debian based system, /bin/sh probably links to /bin/dash instead which leads to some incompatibilities.
You could probably fix your problem by coding in dash instead of bash. But I would recommend gherald's solution instead as that keeps your crontab nice and tidy. It's a bit safer too...
I can chime in here, I've worked with large datasets in scientific research. Today, many scientific formats support built-in compression, but it is still common to find older data sets stored in a large number of non-compressed files. Data sets often use some kind of folder hierarchy, but tarring a whole dataset will result in a really big bulky file. If you then compress that archive, it will take forever next time you need to access that single record in a specific file since you need to uncompress from the beginning of the archive and work all the way down to the file you're looking for.
An alternative is recursive gzip which can save you time by keeping the full file-tree visible without decompressing and allowing you to decompress solely the file of interest. Out of curiosity, I've also run some tests on this, and gzipping large files (with slightly varying content but same format) tends to use less disk space (a few percents) compared to archiving first and then compressing.
Sometimes, I've even built archives out of compressed files (tar -cf data.tar *.gz) to save a bit of time; but this is more related to limitations on systems I've worked with, where I'm not allowed to use scp, but have to rely on gui file transfers :o
There are other ways of doing this, I'm sure, but as in most jobs, whatever quickly gets the practical obstacles out of the way without too much fuss usually sticks. (E.g. I have colleges who will simply fill their shelves with usb-disks in order to avoid compression altogether).
Simple fix: install emacs https://www.emacswiki.org/emacs/CoffeeMode
I use a script for this which I creatively named start_at_exit.sh. It's takes 2 arguments the first is the name of the running process and the second is the command you wish to run when the running process had finished.
It's basically a while loop which checks the first argument against pgrep until no process is found. The loop then exits and the new command is executed.
I mostly use it to power off my machine during the weekend after a bunch of long computations have finished.
edit:
link to script: https://pastebin.com/PCzKKyWG
("sleep 10" is more than enough to make the system load unnoticable on my mediocre machines)
I think the main problem here is that cron is probably not running /bin/bash but /bin/sh. On some systems this might not be a problem since /bin/sh points to /bin/bash.
Since you are running a Debian based system, /bin/sh probably links to /bin/dash instead which leads to some incompatibilities.
You could probably fix your problem by coding in dash instead of bash. But I would recommend gherald's solution instead as that keeps your crontab nice and tidy. It's a bit safer too...
I can chime in here, I've worked with large datasets in scientific research. Today, many scientific formats support built-in compression, but it is still common to find older data sets stored in a large number of non-compressed files. Data sets often use some kind of folder hierarchy, but tarring a whole dataset will result in a really big bulky file. If you then compress that archive, it will take forever next time you need to access that single record in a specific file since you need to uncompress from the beginning of the archive and work all the way down to the file you're looking for.
An alternative is recursive gzip which can save you time by keeping the full file-tree visible without decompressing and allowing you to decompress solely the file of interest. Out of curiosity, I've also run some tests on this, and gzipping large files (with slightly varying content but same format) tends to use less disk space (a few percents) compared to archiving first and then compressing.
Sometimes, I've even built archives out of compressed files (tar -cf data.tar *.gz) to save a bit of time; but this is more related to limitations on systems I've worked with, where I'm not allowed to use scp, but have to rely on gui file transfers :o
There are other ways of doing this, I'm sure, but as in most jobs, whatever quickly gets the practical obstacles out of the way without too much fuss usually sticks. (E.g. I have colleges who will simply fill their shelves with usb-disks in order to avoid compression altogether).
I basically google "what is the name of dmesg" everytime something crashes (slow learner)