0

I've just learned about cron and I've been messing around with it a little bit but I have some doubts about how is it working. From what I suspect, a task is being stopped from performing if it tries to get/send any I/O from/to terminal? I'm asking because I've chained some commands using && and it looked like anytime there would be a stdout/err that wasn't redirected to a file, the rest of the script wouldn't run.

I'm new to Linux so I maybe get this wrong, I hope some of you could explain to me what happens.

L.E: My task would be

* * * * * root apt-get check && apt-get update > /home/user/text.txt && echo "Test" > /home/user/smth.txt

And it looked that because stderr wasn't also redirected to text.txt, the task wouldn't continue.

  • Let us now what your commands are and how your crontab file looks like. – Ravexina Jun 8 '17 at 23:16
  • Sorry, forgot to write it down. – Alexandru Banu Jun 8 '17 at 23:17
  • Actually, it looks like I've messed up something in the path and that's why I wouldn't see the last echo appended to the file. I'm sorry for wasting your time. :( I do have one question tho: I can't use cron to schedule tasks which requires user input? Like apt-get upgrade without using -y. – Alexandru Banu Jun 8 '17 at 23:23
  • As far as I know, no you can't. – Ravexina Jun 8 '17 at 23:25
  • cron isn't bash. Read man 5 crontab. Some programs, (sudo for sure, maybe apt-get) use the isatty - test whether a file descriptor refers to a terminal call (see man 3 isatty) to specifically prevent putting passwords into disk files. – waltinator Jun 9 '17 at 6:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.