As of May 31, 2023, we have updated our Code of Conduct.

Hot answers tagged

3 votes

What things can be done to make a Bash script containing sudo commands, running with the timer schedule ‘crontab’ work?

Instead of trying to trigger a root-requiring operation through your user's crontab, you should use the system crontab, and then you simply don't need sudo, because things are already running as root. ...
Marcus Müller's user avatar
1 vote

save the output to multiple files in crontab

Using tee works with no issues. tty is just the device that is used to interact with the operating system and is located at /dev/tty#. 0 2 * * * /usr/local/bin/ | tee /root/output_all.txt ...
Nasir Riley's user avatar
  • 10.5k
1 vote

How can I "cache" a variable in Bash?

You can store your variables inside a simple plain text file. I used two bash functions for that: # the cache file in /tmp CACHE_FILE="/tmp/your-file.txt" touch "$CACHE_FILE" # ...
alexandre-rousseau's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible