Score:0

Cronjob log shows its execution, but the real script is not executed

fi flag

I have seen these questions, but they have not solved my problem:

Question about cronjobs/bash scripts which are not executed
Cronjob script not being executed

This is my /Temp/RunJob script:

echo $"Bringing all sites up... $(date)" >> /Temp/UpAll
/Base/Commands/Job
echo $"Done $(date)" >> /Temp/UpAll

Please note that it has an empty line at the end of the file as per Linux's standards.

And this is my /Base/Commands/Job script:

echo 'Main job' >> /Temp/JobLog

And this is the output of my crontab -l:

*/5 * * * * /Temp/RunJob 2>/dev/null

Please note that I have an empty line at the end of my crontab file.

And this is the output of grep CRON /var/log/syslog:

Nov 11 06:30:01 server7-paydardata-com CRON[48493]: (root) CMD (/Temp/RunJob 2>/dev/null)
Nov 11 06:35:01 server7-paydardata-com CRON[48619]: (root) CMD (/Temp/RunJob 2>/dev/null)
Nov 11 06:40:01 server7-paydardata-com CRON[48771]: (root) CMD (/Temp/RunJob 2>/dev/null)
Nov 11 06:45:01 server7-paydardata-com CRON[49397]: (root) CMD (/Temp/RunJob 2>/dev/null)
Nov 11 06:50:01 server7-paydardata-com CRON[49564]: (root) CMD (/Temp/RunJob 2>/dev/null)
Nov 11 06:55:01 server7-paydardata-com CRON[49685]: (root) CMD (/Temp/RunJob 2>/dev/null)
Nov 11 07:00:01 server7-paydardata-com CRON[49804]: (root) CMD (/Temp/RunJob 2>/dev/null)
Nov 11 07:05:01 server7-paydardata-com CRON[49924]: (root) CMD (/Temp/RunJob 2>/dev/null)
Nov 11 07:10:01 server7-paydardata-com CRON[50045]: (root) CMD (/Temp/RunJob 2>/dev/null)

And I am the root user. (whoami => root)

And I see that my /Temp/RunJob is actually executed by cron, but I can't see anything related to the /Base/Commands/Job in the logs.

In other words, cron seems to not execute the internal commands of my job.

How can I debug this?

Artur Meinild avatar
vn flag
Please include the full output of: `stat /Temp/JobLog` and `cat /Temp/JobLog`.
Artur Meinild avatar
vn flag
Also output of `stat /Temp/RunJob` and `stat /Base/Commands/Job`.
Ali EXE avatar
fi flag
@ArturMeinild, you can see our complicated scripts and commands [here](https://github.com/hosseinitabar/linux-cron)
Artur Meinild avatar
vn flag
Please be more specific. It seems your question is an "abstraction" - that the file `/Base/Commands/Job` actually does not exist, but instead it's called something else - as well as `/Temp/RunJob` and `/Temp/JobLog`. Please do what I asked, but specifically for the files on the computer. And edit the question to use a specific example. I can't help if you keep asking in abstractions and theories..
Artur Meinild avatar
vn flag
I've downvoted and voted to close until you add 1:1 specific information to the question.
Ali EXE avatar
fi flag
@ArturMeinild, of course it's an abstraction. How can I upload my entire real-world scripts in one SE question? I created a github repo and added the real scripts there. As you can see there, they are interconnected and they use a base. I can't copy/paste them here. I appreciate your time, but I think you can help me **debug** the issue on my side. For example you might say that *cron has verbose flag, turn it on* and it would help.
Artur Meinild avatar
vn flag
See my 1st and 2nd comment, which you haven't included yet. Stats for those files would be part of the debugging (or just choose any one script to use as an example). I'm actually trying to help you, but you're making it really hard for yourself.
Artur Meinild avatar
vn flag
It's really useful that you included the link to the script source files. Now we need to see exactly which scripts are run on your machine, and the contents `cat` and stats `stat` of the relevant script and logfiles.
Artur Meinild avatar
vn flag
In you github, the script `RunJob` writes to `/Temp/UpAll` and calls `/Company/ServerLinux/Commands/Up`. Maybe check if this is correct?
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.