Hot answers tagged

15

This syntax 30 15 */15 * * is correct, but it is not doing the same with this 30 15 1,15 * *. The latter will execute command at 1st and 15th of the month, as it has fixed comma separated values for the "day of month" field. The / defines steps, that means */15 will execute every 15 days, starting from 1, that means: 1st, 16th (for all months) and ...


5

Putting the variable in the crontab file and in the environment is secure in the sense that other users can't access it. However, it runs the risk of accidental disclosure, for example if you post the crontab line when asking for debugging help, or if you copy it and send it to someone as an example of how to automate running the script, or if some process ...


3

The valid hours range is 0-23, so you should use */15 7-18 * * * to run every 15 minutes from 07:00 (first run) to 18:45 (last run) every day. The leading zero for the hour range (07) was the cause for the hour field to be assumed as *. I tested (cronie-1.5.1-lp151.4.6.1.x86_64 on suse) that the behaviour is same to your description, for a range, like * 01-...


2

While comments are probably more readable on a line of their own: ## This is commented out because the frobication goes foobar /ilkkachu 2020-11-01 # 00 20 * * * sh test.sh you should also be able to put comments after the command: 00 20 * * * sh test.sh # frobnicate the sales data This should work because the shell considers # as starting a comment, ...


2

I suggest you to have a clear syntax, every comment in its own line(s), above the command that is commenting. # comment this is doing that 0 0 * * * command # Uncomment this line to do this. Comment line if that. The reason is this. #0 0 1 * * command # comment text 0 0 1 * * command If your comment is (short and) explanatory enough, there is no ...


2

Cron only executes commands, you can make it execute a binary or a script as you wish, including a PHP script if you feel like it. You could technically execute a script that would use curl to GET an URL, and include your variable in the URL, or you could POST to an URL and add your variable to a header.


2

The command would be something like grep "$(date +'%d/%m/%Y')" server_log.txt where date +'%d/%m/%Y' generates todays date in the given format, i.e. 06/11/2020.


1

There is no non-networkmanager command that is being launched when you activate the openvpn connection through NM. This is an internal procedure within NM that sets up the connection. To manipulate it through the command line you can use the nmcli command. Some kind of command like this should work: nmcli connect up "name of the openvpn connection" ...


1

Your script appears to assume that it is executed with a particular directory as its current directory. Make sure that the current directory is set appropriately at the start of the script by using cd. For example, if the cms directory is located in /some/dir, then use something like #!/bin/bash if ! cd /some/dir; then echo 'Failed to cd to /some/dir' &...


1

Why do you need 2 different crontabs (it’s not possible on user level, only on sistem level in /etc/cron.d - there in separate files you can specify the user which runs the cron)? Simply make 2 lines in one crontab each with a different schedule. Or a different command/script to execute, which will check your condition and decide whether to run some commands ...


1

The secret (as pointed out by @waltinator is to set DISPLAY correctly. That should probably be DISPLAY=:0 The format there is typically hostname:displaynumber, where hostname is optional. The second issue is display security. If you put the cronjob in your own crontab instead of root's, then xhost should not be needed as xauth will work. OP has (probably) ...


1

I don't know if it helps to anyone, but here is my experience. I configure ssmtp just to send emails from my Ubuntu 18.04 server. What cause me the error was that gmail had "less secure apps off", this caused that google couldn't authenticate my server's certificate. Once enabled, I could start sending emails from the server. Hope it helps!


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