New answers tagged

0

Probably the simplest way of doing this with cron is to: start the torrent service at time T1 for each user in user group A stop the torrent service at time T2>T1 for users in group A start the torrent service at time T2>T1 for users in group B stop the torrent service at time T3>T2 for users in group B Choose times, e.g. T1 is anywhere between 0:01 ...


2

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 ...


3

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

Really awesome solution....! It works for me perfectly. Thanks.... $command = "wget 'URL WITH QUERY STRING'"; exec("$command >/dev/null &");


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 ...


0

Put the command into shell script and set the cronjob to run that shell script but not mongodump command


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 ...


0

The format used for the crontab file /etc/cron.d/testing is correct. (It should be, it was copied from /etc/cron.d/anacron) The problem was that I modified it from Windows and probably messed up the line endings. I re-cloned anacron, edited it on Ubuntu, and everything worked. (I still don't know where the error message, if any, was logged.)


0

*/5 * * * * /path/to/script Make the script executable before that. And make it accessible only for root if the script need elevated privileges. You can follow the link for more examples Here


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 ...


0

More commands : sudo cat /var/log/dpkg.log | grep "\ installed\ " >> installed.txt ls -tl /var/lib/dpkg/info/ | grep list >> ls-tl-installed.txt


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 ...


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 ...


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 ...


1

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


0

I think your Cron service not started. Try: service crond start You can check Cron service status with: service crond status Make sure your script file has execute permission.


0

My bash script for backup MYSQL to S3. SERVERNAME="YOUR_SERVER_NAME" TIME=`date +"%Y-%m-%d-%H-%M"` FILENAME="backup-DB-$SERVERNAME-$TIME.sql.gz" DESDIR="/var/backfile" mysqldump -u root -pYOURPASSWORD YOURDBNAME | gzip -9 > $DESDIR/$FILENAME /usr/bin/aws s3 cp $DESDIR/$FILENAME s3://YOURS3BucketName /bin/rm $DESDIR/$FILENAME ...


0

does the script work, if you execute it yourself? if so - try replacing /bin/sh in the crontab with /bin/bash +x and replace /dev/null with /tmp/debug-mysqlbackup.log - this will output all steps to the file /tmp/debug-mysqlbackup.log (still can't create comments ... ;-D)


0

Some Basics cron A user can utilize the crontab utility to edit his/her crontab. The cron daemon will consume all crontabs and run the commands at the defined interval. A crontab entry basically looks like this: * * * * * /path/to/some/command mysql backup Backup of a mysql database can be achieved through various methods; depending on database engine ...


0

Assuming you have installed aws-cli (and the machine has a IAM role with permission to upload to S3) and mysqldump in the machine you want to run the cron job, this is the way I do it: mysqldump --defaults-file="path_to_config_file_with_password" -u db_user -h db_hostname db_name_you_need_backup | gzip -9 > db_name.sql.gz; now=$(date +"%m_%d_%Y") aws s3 ...


0

That script needs you to define root password for you database and you S3 storage's bucket name. So edit it first then try executing it. That command skips information_schema, performance_schema, mysql & test databases which usually not needed for backup porposes. I would suggest for you to replicate current setup of your database to a development ...


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 ...


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 ...


-1

man 5 crontab will solve your problem. It says, in part: An active line in a crontab will be either an environment setting or a cron command. An environment setting is of the form, name = value where the spaces around the equal-sign (=) are optional, and any subsequent non-leading spaces in value will be part of the value ...


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.


0

Anacron is not a daemon; it's just a program that's run by cron. This is explained in https://help.ubuntu.com/community/CronHowto, near the bottom, under the heading How Anacron is Set Up. According to that article, "anacron is run on every startup, wake up, plug-in, and at 7:30 AM every day." To quote from that section of that article: There is a ...


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.


0

TRIM does not work through USB, but usually you get a message about "unsupported ioctl" when you run it on such a device (external USB disk enclosure). Confirm that your mmcblk0 is really not on USB: lsblk -o TRAM,SUBSYSTEMS,NAME,TYPE My SD cards on mmcblk0 do not list a TRAN, but seem to appear under the USB branch since it follows a USB, but adding the ...


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/...



Top 50 recent answers are included