O
O
OLZ12021-02-03 11:29:07
Task Schedulers
OLZ1, 2021-02-03 11:29:07

cron scheduler: user script not executing.?

Linux Mint 20.1 Ulyssa (Cinnamon 4.8.6)
The bottom line is this. The scheduler is assigned a regular task of executing a certain scenario when the computer is turned on/rebooted.
Let's say that a simple cleaning of the contents of a file is accepted as a script .bash_history:

#!/bin/sh
> ~/.bash_history

This script is included in a separate executable simple_script. When "manually" running this file, no errors occur: the required file is cleaned "as it should" ( $./simple_script--> ok)
But there was a need to be bolder - and ask the cron scheduler to perform this task itself.
At the same time, the specific execution time of the script is not prescribed: it is necessary to perform this task at system startup (=> the keyword @reboot => anacron is used).
My steps are the following. For convenience, I place the above file in the /etc/cron.daily folder simple_script("to be sure"), and in the same place I create an executable file run, in which it is written:
#!/bin/sh
@reboot /etc/cron.daily/simple_script

Then I restart my computer and nothing happens.
What is wrong with these actions? Or rather, how to accomplish the task set using the @reboot parameter without modifying the configuration file?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Saboteur, 2021-02-03
@OLZ1

1. The crontab service has a current directory that is different from the one your user is in, so ./simple_script could mean that simple_script should be in the root directory. First, try specifying the full path to the script.
2. In your particular case, you are using the system cron, not the user one. ~/.bash_history will refer to the current user, which in this case will be root
Precisely, root does not clear history on reboot?

V
Vitsliputsli, 2021-02-03
@Vitsliputsli

Where did /etc/cron.daily come from? Scripts from there start only once a day at a certain time. Use a regular cron list.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question