Hot answers tagged

9

You have carriage return (CR) at the end of the line, as the log says: /home/log-transfer-user/scripts/execute_script.sh^M You need to remove the CR and also put a newline after the line as needed by cron.


6

Each crontab line must start with a time at which the command should be run and then the command. The general format is: Min Hour Day Month DayOfWeek Command So, to run command at 10:15 every Sunday, you'd do: 15 10 * * 0 command I'm not sure what your commands are, but you have lines that don't start with a time definition. I don't understand what ...


4

These logs are already generated automatically. You can view the files in /var/log/apt. There is a history.log which logs all executed apt commands, like this: Start-Date: 2016-07-06 14:29:04 Commandline: apt upgrade Requested-By: bytecommander (1000) Upgrade: tzdata:amd64 (2016d-0ubuntu0.16.04, 2016f-0ubuntu0.16.04) End-Date: 2016-07-06 14:29:06 The ...


4

If you are not opposing bash solutions, here's a script that does what you outlined. It can be added to /etc/rc.local to run on every boot. Just call it like bash /path/to/script & from within /etc/rc.local #!/bin/bash while true do screen ./run.sh arg1 arg2 "arg3" & # start in background CMDPID=$! # get pid of that command TIME=$( date ...


3

Make the script executable by: chmod u+x /path/to/script.py Note that, you need a shebang (i.e. indicate interpreter in the first line of the script), for python2: #!/usr/bin/env python2 For python3: #!/usr/bin/env python3 Open your cron table by crontab -e Add the following cron entry: */10 * * * * /path/to/script.py Note that, if the ...


2

Sometimes running a process from root's crontab may cause issues with initial file ownership and rwx mode; those may not be correctly preserved. In any case: 1) to create a new user, keep it simple: $ sudo deluser my-user # if "my-user" is a regular user $ adduser my-user $ sudo gpasswd -a my-user sudo 2) to include a new entry with a NOPASSWD tag ...


2

You should handle these kind of issues with logrotate, it is designed for these tasks specifically. For example, to enable logrotate to rotate the file /var/mail/root if the size of the file becomes 10 MB, you can add a logrotate configuration file e.g. /etc/logrotate.d/mailroot with the content: /var/mail/root { size 10M # Rotate if the size is &...


2

There is not really a need for a bash script. First, work out what backup command would work for you. In principle, you could do something as easy as: mysqldump > /path/to/mysqldump.sql 2>/path/to/mysqldump.err This will write the contents of all the data bases to a file called mysqldump.sql. The form of this is such that, if you need to restore the ...


2

Check to see if .selected_editor exists in /root/ if you are logged in as root, /home/$USER directory if you are not logged in as root. If it does exist, then remove the file with one of the below commands: For root user: rm /root/.selected_editor For non-root user: rm /home/$USER/.selected_editor


1

There are two methods to solve this situation, one which uses a system command, and another more manual method. Select-editor command Use the command: select-editor Which will give you another attempt at using the number-based system to select the default text editor. Manual Method: If it does not already exist, create the .selected_editor file for ...


1

To avoid cron, you could also call your script in an infinite loop with a delay of 10 minutes. If you want to launch the script again 10 minutes after the previous instance exited, use this: while true ; do /PATH/TO/SCRIPT.PY ; sleep 10m ; done However, if you want to launch the script every 10 minutes on the clock, no matter how long the last instance ...


1

Try the following code in your terminal sudo service mysqld restart I think thats what your looking for


1

Try (in terminal): $ crontab -r where the -rflag removes current crontab configuration. You can also use $ crontab -e and manually delete everything inside. Other options are: -l to list crontab configuration -e to edit crontab configuration To edit someone else's crontab you can use -u followed by the corresponding username.


1

Ah, now I undersand! That's a fairly common request: All you need is to test for the existence of a given file, not its content. E.g. if you want to run the cron job, create a file say in yr home directory: $ touch /home/you/cronjob_enable. Then edit yr user crontab: $ crontab -e */5 * * * * /bin/bash -c 'test -e /home/you/cronjob_enable && /home/...


1

To run a crontab as user www-data you can use the following command: crontab -u www-data -e Then you write a line, for example to run a php file every 15 minutes: */15 * * * * php -f /path_to_cron/cron.php When saving it, you will be asked by the editor: File Name to Write: /tmp/crontab.HMpG7V Save it there, no worries. crontab -e opens a file ...



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