date int64 1,220B 1,719B | question_description stringlengths 28 29.9k | accepted_answer stringlengths 12 26.4k | question_title stringlengths 14 159 |
|---|---|---|---|
1,536,240,873,000 |
I've got a Pi2 (running Raspbian Jessie) nicely set up with a 2Tb external USB drive (sda) set up so that I am booting off of /dev/sda1 (16Gb), downloading torrents to /dev/sda2 (200Gb) and saving all my important documents on OwnCloud /dev/sda3 (1.7Tb)
df -h:
Filesystem Size Used Avail Use% Mounted on
/dev/root... |
What kinds of danger do you expect? Data loss, of course, but how do you expect that data loss to happen? This immediately rules out several strategies. Regardless, RAID is not a backup. Some of the RAID levels (1,5,6,…) merely provide a way to keep your system running if a disk fails.
If there's an error in your sys... | How can I prevent data loss (after install) |
1,536,240,873,000 |
I am installing new crontab job which will execute a shell script and then send the printed errors on the console to email.
I know all of the required steps to do, which will be as following:
0 10,22 * * * . /X.sh 2>&1 >/dev/null | mail -s "subject" "email"
Mu question is: when will it send the email?
it will send... |
The email will be sent every time X.sh finishes running, whenever that is.
cron itself will send a job's output by email by default, to the relevant crontab owner or whatever MAILTO is set to; you could use that instead of manually calling mail.
| crontab each 12 hour - when will it send an email? |
1,536,240,873,000 |
So i created a script used to backup system, i tested and it worked.
Here's the script:
#!/bin/bash
backup_files="/home /var/spool/mail /etc /root /boot /opt"
dest="/mnt/backup"
day=$(date +%F)
hostname=$(hostname -s)
archive_file="$hostname-$day.tgz"
echo "Backing up $backup_files to $dest/$archive_file"
date
echo
t... |
Unless your script is not executable (fix that with chmod +x /root/backup_system.sh) or the crond isn't running, there's nothing obviously broken in your script that will prevent it from running.
All of the commands you use (date, hostname, tar, and ls) should be in /bin, which should be in the default PATH....unless ... | My backup_system.sh file didn't run under crontab |
1,536,240,873,000 |
I am looking for some script or terminal command to list all the scripts (preferably with their paths) which are run on a periodic basis by cron, cron.daily. I am not looking for any filter for time-period of the script and want all the scripts listed ( however some administrators may want this kind of filter).
Purpos... |
To find the filenames and script types of all scripts run from cron by non-root users (does not identify user):
find /var/spool/cron/crontabs/ -type f ! -name 'root' \
-exec awk '!/^[[:blank:]]*(#|$)/ {print $6}' {} + |
xargs -d'\n' file | grep -i script
/home/cas/scripts/fetch.sh: Bourne-Again sh... | Get a list of all scripts and their paths which are run as cron job |
1,536,240,873,000 |
I am trying to port the code over to a new server hosted somewhere else, and I want to know what cron jobs are running on the old box.
Where can I find these?
crontab -l
SHELL="/bin/bash"
0 0,6 * * * php-cli /home/mycompany/public_html/index.php cron get_review_data
0 0 * * * php-cli /home/mycompany/public_html/index... |
The functions called (get_review_data, save_stats, check_for_new_reviews, etc.) should be listed within the php code and python code, /home/mycompany/public_html/index.php and /home/scraper/scraper.py
Examining those files should show what's actually being executed.
| Where are my lost cron jobs? |
1,536,240,873,000 |
So I've made a basic .sh file to clear my cache using the
sync; echo < 3 /proc/sys/vm/drop_caches
command. Then I saved it to my username in
/home/marc
Then I came across the crontab so I decided to use this sh file with crontab to run every hour as I noticed that my RAM is eaten up extremely quickly on my laptop. ... |
The simplest answer to check if a cronjob works when you expect it to (short of reading the man page) would be to add a simple cronjob that will report the date to a particular file:
0 * * * * date >> /tmp/cronjob.test
Then check it the next day (or whenever) and ensure it's triggering when you expected it to.
I pers... | How to check if a crontab job works when it should |
1,536,240,873,000 |
I've got a shell script. It is supposed to be executed automatically on and on over time. Maybe about three times a day. But I don't want to write a cron job for it since it's not the same time every day. Rather, my shell script knows after execution by itself when it wants to be executed for the next time. Is there a... |
Do you have the possibility to install the at command ? (sudo apt-get install at)
If so, you can add a call at the end of your script, and timing it with the parameters you want
For example, you can add this at the end of your script to execute it again 2 hours later:
at now +2 hours -f myScript.sh
| Shell script says system when to execute for the next time |
1,536,240,873,000 |
There are multiple options - with cron - to start your script at a specific time, but is one more secure over the other?
My question is simple:
What's the difference between adding scripts in the /etc/cron.daily/ or editing in your script in crontab(-e)?
What I'm worried about is that other users are able to see th... |
The system-wide scripts in /etc/cron* are world-readable by default. For example, on my Arch:
$ ls -ld /etc/cron*
drwxr-xr-x 2 root root 4096 May 31 2015 /etc/cron.d
drwxr-xr-x 2 root root 4096 May 31 2015 /etc/cron.daily
-rw-r--r-- 1 root root 74 May 31 2015 /etc/cron.deny
drwxr-xr-x 2 root root 4096 May 31 201... | What's the difference between adding scripts in the /etc/cron.daily/ or editing in your script in crontab(-e)? |
1,536,240,873,000 |
Suppose the computer is being launched irregularly. And I want to run a certain script at boot time once in a month. But I can't setup a cron job as I don't know whether the machine will be booted at this date.
I though about this approach.
I create a file with last date time of script execution.
Every boot I do the... |
Just* run it at either schedule using cron and check the other part of the schedule in the script:
One way:
@reboot /path/to/my_script.sh
if has_run_this_month() {
exit
}
Other way:
0 0 1 * * /path/to/my_script.sh
if has_run_since_reboot() {
exit
}
* There are several issues with this way of running things... | Run certain script periodically at boot time |
1,536,240,873,000 |
I'm looking for a way (bash script or other) to make a command run every minute using date - I've been looking around for similar solutions but they all suggest either cron or watch but what I want to do is to execute the command according to the output of date so that I could make the command run when the second hand... |
#!/bin/bash
until [[ $(date +%S) -eq 30 ]]
do
sleep 0.75
done
while true
do
#command &
#here your cmds should be forked to background to avoid delaying
date +%S
sleep 30
done
edit
as you wanted to see date +%S stdout and check if = 30 and execute somthing!
#!/bin/bash
foo(){
echo yay
#add commands ... | Execute a command every minute forever using 'date' |
1,536,240,873,000 |
I have a bash script that users while do along with sleep to constantly monitor the connection state and take measures in case something goes wrong. The only thing that is not guarded is the execution of the checking script itself.
I'd like to have the myscript.sh executed at startup via init.d entry and then have CRO... |
With a modern init system (like systemd or upstart), you could just have the init system take care of restarting the script if it fails.
If for some reason you're stuck with a legacy system, you could have the script periodically update a flag file (touch /var/lib/myapp/flagfile), and then via cron check if the flag f... | Have cron check if the bash script is executing |
1,536,240,873,000 |
I am trying to deploy a script to agents and run the script using cron every hour. When I am running puppet agent -t I am getting error:
Error 400 on SERVER: Invalid parameter path on Cron[homebackup] at
/etc/puppet/modules/homebackup/manifests/init.pp:16 on node
In the manifest I wrote in path: /etc/puppet/mod... |
The immediate issue is that your file (script.sh) needs to be in the files directory under the module, i.e. /etc/puppet/modules/homebackup/files/script.sh. Confusingly, the files part of the path is not part of the source URI.
You also have another error: The File requirement AFAIK needs to refer to the name of the fi... | Unable to run the script in cron via manifest |
1,536,240,873,000 |
I am running Apache server on lubuntu linux, Since there are plenty of applications ruining on the web server with 10+ users accessing the server regularly, the server logs [access & error logs] gets piled up to huge size.
I cannot turn off them since we might need to monitor them for security as well as we use the lo... |
As mentioned in a comment, logrotate does this for you already. Just install (if it's not already installed) and enable it. Trying to do this with a custom cron job as @Dave mentions, while perhaps functional, is really not a good idea for your long-term sanity.
| Whats the best way to clear / empty Apache log files periodically |
1,536,240,873,000 |
My server always shut down when it reach a high load average. I have optimized my Apache, MySQL. But I cannot prevent sometime in a heavy traffic. So I try to write some shell to control load average.
#!/bin/bash
check=`uptime | sed 's/\./ /' | awk '{print $10}'`
if[$check -gt 5]
then
/usr/bin/systemctl restart htt... |
You must separate the brackets from the data with spaces, like this:
for I in 0 1 2 3 4 5; do
check=$(uptime | tr -d ',.' | awk '{print $10}')
if [ "$check" -gt 5 ]; then
/usr/bin/systemctl restart httpd.service
fi
sleep 10
done
In UNIX, [ is really a shell command. When the shell replaces the... | auto restart Apache when high load average |
1,536,240,873,000 |
At work on our linux servers, I have a standard non root account.
Unfortunately the account does not have permissions to crontab or at.
Is there a good reason to block these commands?
I can write a script that uses sleep to do the stuff I want to schedule but I would rather do it in either cron or at.
|
It slightly simplifies system administration, because users can be locked out by using /etc/nologin and kill, without having to worry about processes coming back through cron or at.
It shouldn't be a big problem if you can run your own cron daemon.
| Is there a good reason to prevent users from using cron/at? |
1,536,240,873,000 |
I am studying linux on my raspberry pi that installed debian version.
There were no problem, worked perfectly in crontab, but something has occured.
@reboot sudo bash /home/pi/IP_check.sh
*/10 9-24 * * * sudo bash /home/pi/IP_check.sh
Shell script has no problem, but don't work at every 10 mins.
There is not any lo... |
That crontab entry is invalid, maximum value for hours is 23, not 24. Hence that line is rejected. You should have gotten an error after adding it.
| In crontab, @reboot is working but regular not working |
1,536,240,873,000 |
CentOS 5.x
I noticed that someone (presumably another admin) added an entry directly to the bottom of /etc/crontab so it reads like:
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root ... |
From running the command in the crontab file there is no difference. At least Vixie cron (as on CentOS) checks every minute if the spool directory's modification time or that of /etc/crontab has changed.
However if you edit via crontab -e, and write the crontab will be checked for glaring errors. E.g if the last line ... | Are there disadvantages/consequences to adding scheduled tasks directly to /etc/crontab instead of using the crontab command? [duplicate] |
1,536,240,873,000 |
Having issues making crontab run certain commands, despite the PATH and SHELL being set correctly.
Here is the env of the machine:
SHELL=/bin/bash
USER=ubuntu
MAIL=/var/mail/ubuntu
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/gopath/bin
Here is the env of cron (looks ... |
You shouldn't quote the cron job.
You have
*/1 * * * * "whoami && which whoami"
Which is looking a command literally called whoami && which whoami. Such as /usr/bin/whoami && which whoami. Obviously, this command does not exist. Remove the quotes so that the command is properly interpreted:
*/1 * * * * whoami && whic... | cron will find certain commands on the PATH but not others |
1,536,240,873,000 |
I want to execute all cronjobs in the environment defined in my ~/.zshenv, and I want to redirect STDOUT and STDERR of every cronjob to a single log file. I am on OS X 10.9. What is the cleanest way to achieve this?
|
~/.zshenv is loaded by zsh when it starts (except when started with -f or if the configuration directory is changed by setting ZDOTDIR). It is not loaded (cannot be understood) by any other shell. So arranging load ~/.zshenv is equivalent to arranging for your jobs to be executed by zsh. Set the SHELL variable in the... | Execute All Cronjobs in ~/.zshenv Environment |
1,536,240,873,000 |
I have added a crontab entry via crontab -e for the current user:
@reboot supervisord -c /etc/supervisord.conf
Yet after the reboot, supervisord demon is not running. I need to run the command again in bash. Only a second try yields in an error I expected right away after setting up the cronjob.
$ supervisord -c /et... |
cron by default running in a minimal environment, from man 5 cron:
Several environment variables are set up automatically by the cron(8)
daemon. SHELL is set to /bin/sh, and LOGNAME and HOME are set from the
/etc/passwd line of the crontab's owner. PATH is set to
"/usr/bin:/bin". HOME, SHELL, and... | Why doesn't my supervisor daemon start on reboot? |
1,396,342,628,000 |
I'm using:
# cat /etc/redhat-release
CentOS release 6.4 (Final)
Have an script in user's crontab:
$ crontab -l
0 7 * * * /home/teamcity/scripts/TC_backup.sh
If I run this script under this very user - it's create needed archive:
$ /home/teamcity/scripts/TC_backup.sh
...
And from local-scripts-log:
$ cat /var/log/te... |
Сause was in JAVA_HOME variable, as it needed by maintainDB.sh script.
So, getting info from script running from cron:
getenv () {
env >> $BDIR/envlog.log
}
...
getenv;
...
And than checking file to variable:
$ cat envlog.log | grep JAVA
Show nothing.
After adding:
...
export JAVA_HOME="/usr/java/jdk1.6.0_45/"
expor... | Script from cron doesn't create archive |
1,396,342,628,000 |
INPUT:
* * * * * ( /path/to/foo -x )
3 * * * * /full/path/tothing
3 3,2,4 * * * /full/path/tothing4 3
OUTPUT:
( /path/to/foo -x )
/full/path/tothing
/full/path/tothing4 3
Q: How can I truncate the line until the fifth space?
|
Here's a way:
$ crontab -l|sed -r 's/([^[:space:]]+[[:space:]]){5}//'
| How to only output commands from CRON? |
1,396,342,628,000 |
Is there a way, in Linux or FreeBSD, to receive notification from system at a specified time? I'm thinking something in like of what inotify in Linux does for filesystem events.
There IS a way to that using cron, but I'm asking if there is a lower-level interface that can be called programatically. If cron is an 'offi... |
There are two low level interfaces that I'm aware of:
One is simply to do a sleep() until that moment when you want to receive the notification. The sleep call is provided by glibc.
The other method would be the alarm() system call. It allows you to tell the kernel that after a defined amount of time has passed it sho... | Get system notification at a certain time? |
1,396,342,628,000 |
I have a couple of cron jobs set up to maintain a local copy of a remote database.
The first one downloads the latest version of the database from the remote machine, which runs every day and is working fine.
The second one imports the downloaded data, however it is not working.
The job is just a simple shell script:
... |
remove the bash, just have the following and it should work:
0 8 * * * /home/lampadmin/cron/my_db.sh
also check that my_db.sh is executable.
chmod a+x /home/lampadmin/cron/my_db.sh
| Cron job not running / not successful? |
1,396,342,628,000 |
I disabled all my cron jobs by putting a # in front of them. Except for one:
@reboot echo "Hi I rebooted"
The rest are:
#0 2,14 * * * /home/backup1/mysql-backup.sh
#0 * * * * mono /root/apps/AlertAuth.exe
However, my inbox gets this message
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20... |
Debian's cron, like many other modern variants, read jobs in files under directories called /etc/cron.d, /etc/cron.hourly, etc., in addition to the traditional /etc/crontab. In particular, the job you see comes from /etc/cron.d/php5 which is installed by the php5-common package.
| PHP phantom cron job |
1,396,342,628,000 |
OS : Ubuntu 12.04
Now I want to use Backup and Whenever gem to automatic backup my database. When I connect the server by ssh as an added user to run backup perform -t my_backup,it works well.But the cron file:
0 22 * * * /bin/bash -l -c 'backup perform -t my_backup'
can't run at 22:00. When I use cat /etc/crontab ch... |
The special crontab file /etc/crontab has a slightly different format in that the sixth field must be the user the cron job will be run as. So if you want to put your job into that file, you must insert a user name between * and /bin/bash to match the format. Something like:
0 22 * * * root /bin/bash -l -c 'backup p... | Why isn't cron running automatically? |
1,396,342,628,000 |
I have a MAMP setup which runs PHP 5.3.5 on my Mac OS X 10.5 computer. I am trying to install a crontab that executes a PHP script, which is located on my MAMP server. I can only get the crontab to execute if I use the php installation from /usr/bin/php, which is version 5.2.15. In other words, this is the pre-install... |
The SHORT answer:
Ultimately, I just installed the newest version of PHP onto my system.
The LONG answer (and all the pain I endured along the way):
I kept getting an error when crontab would run, which stated that a certain class that I instantiated in my script – SoapClient – was not being found. My autoload functi... | How can I get crontab to use a different PHP installation location? |
1,396,342,628,000 |
I am on Debian 11 testing. It's a low-end computer intended for users with little computer experience and I want to keep it up to date with a script that do not prompt users for a password.
Following the advice of several topics (like here):
So I wrote a simple script /home/user/Documents/update.sh like this:
#!/bin/b... |
The most basic thing you can do is prefix /usr/bin to your script:
#!/bin/bash
sudo /usr/bin/apt update -y
sudo /usr/bin/apt upgrade -y
sudo /usr/bin/apt autoclean -y
sudo /usr/bin/apt autoremove -y
This will work because you allowed the user to run /usr/bin/apt but not apt. That's actually good because it stops som... | Debian : how to use a sudo bash script without password at startup |
1,396,342,628,000 |
I have multiple cron jobs in one crontab (as usual). One of the jobs interacts with a remote system in another timezone, which means I need to adjust the crontab every time either timezone enters or exits daylight savings.
I know I can set CRON_TZ to control what timezone cron uses for all jobs, but is there a way to ... |
Using systemd timers, you can define what would classically be Cron jobs as timers, which race to an OnCalendar= specification, which can incorporate time zones.
Regarding the mentioned hurdles switching away from cronjobs: at least the recurring time event specification allows for basically the same functionality; so... | Use a different timezone for one cron job? |
1,396,342,628,000 |
I currently have one perl script that is used to make a memory intense call to another protocol. This takes approximately 20-25GB ram to complete. And, it takes anywhere from 8 to 15 minutes. Upon completion, I export that data to another perl script that processes it and submit to a discord bot for me.
The problem I'... |
cron isn't quite that flexible with this sort of thing and sleeping for five days at a time is not going to be entirely reliable in a couple of ways.
One solution would be to bake the "every five days" logic into a wrapper script and set it up in cron to run every single day. So something like this is one approach:
u... | Repeating perl script every 5 days, not nth day of month |
1,396,342,628,000 |
At my job we have a Linux server with several cron jobs with the syntax wget -O /dev/null followed immediately by an http request to a PHP file or whatever. So something like wget -O /dev/null "http://foo.bar.com/file.php".
I've been able to find out what the various pieces of it mean individually:
wget: An app that ... |
/dev/null is (pseudo-)device file that just discards everything that's written to it. There's no renaming involved there, wget -O file just opens the named file (possibly creating it) and writes there. In this case with /dev/null, the operating system just discards the written data.
The end result is that the URL in q... | Linux wget -O /dev/null <http....> syntax |
1,396,342,628,000 |
With incrontab, I want to monitor a file and whenever it gets modified, I want to replace a string in it. But that will create an infinite loop, I guess. When I configure it with the following table:
/etc/file.md IN_MODIFY sed -i 's/Hello/Hi/g' $@
It works once, but never again. I don't see any error messages an... |
It turned out that I was not having an infinite loop, but I was experiencing this bug.
The service that modifies the file that I am monitoring, does not just modify the file, but deletes and recreates it. Through the deletion, incrond stops watching it, which can be determined when event IN_IGNORED is logged. That's w... | incrontab: modify a modified file |
1,396,342,628,000 |
I've edited my root crontab to periodically execute a script:
sudo crontab -e
Which should execute the following script, located on a mounted USB, as root:
* * * * * /mnt/usb0/fake-hwclock-cron.sh
The script (1) fake-hwclock-cron.sh then runs the script (2) fake-hwclock to save the current time:
#!/bin/sh
echo "$(fa... |
Based on the output of the mount |grep usb0 it shows that the mount point is mounted by the noexec option and it will prevent you just executing the script but you can do execute it with shell interpreter directly like:
* * * * * sh /path/to/script.sh
for the later error fake-hwclock: not found, you would need to pro... | bash script in cronjob cannot execute /sbin/fake-hwclock |
1,396,342,628,000 |
I have a crontab that works as expected when my mac is awake but seems not to run when the mac is asleep even though I've scheduled the it to wake up a few minutes before it's supposed to run. In the crontab I've forwarded the output and errors so I can see if anything is failing, but these are also not updated so I g... |
I was able to get it this to work using pmset. Specifically, I just ran the line pmset repeat wakeorpoweron MTWRFSU 08:59:00!
| Crontab not running when mac asleep despite scheduled wakeup |
1,396,342,628,000 |
I'm trying to execute a bash script on Linux startup, but it doesn't work. I have tried all of these commands in the crontab:
@reboot bash /home/user/mysqlamazon.sh
@reboot sh /home/user/mysqlamazon.sh
@reboot /home/user/mysqlamazon.sh
@reboot sleep 60 && /home/user/mysqlamazon.sh
I have another command on crontab wh... |
You don't tell us how this fails, but I am guessing you don't see it executed.
First of all, your script will never work since while($true) isn't valid shell syntax. I assume you want something like this:
true=1
while(($true)); do ... ; done
The more common idiom for that is:
while : ; do ... ; done
Or (true is a co... | Bash script working in root but not in crontab |
1,396,342,628,000 |
I can't get this cron to run.
being new to linux, I really don't know my way around.
Pi 3B+
Debian 9 Stretch
PHP 7.0.33
Nginx 1.10.3
Pi has OpenMediaVault ( OMV ) running.
Used OMV to create a sharedfolder 'www' which I can access and also map to my PC as a network folder.
I have php scripts in the www folder and they... |
The path to the file is /sharedfolders/www/testcode/push2.php, not /mnt/fs/sharedfolders/www/testcode/push2.php.
From comments, it appears as if you're put into a chrooted environment under /mnt/fs when you log in using ssh. This is why the pathname of the file starts with /sharedfolders rather than with /mnt/fs. Th... | Pi cron php not running |
1,396,342,628,000 |
I have a shell script to download files from S3. I'm able to run the script manually and it's working fine, But when I schedule it from Cron it's triggered but except the echo command, nothing is executed.
Script
#!/usr/bin/env bash
set -e
echo "starting"
y_day=$(date --date="-1 day" +%d)
y_month=$(date --date="-1 da... |
The primary issue seems to be that the aws command is not found.
You could solve this in one of two ways:
Use the full path of the command each time you invoke it in the script.
Modify PATH in the script to include the path of the directory where the command is found.
See also:
When is double-quoting necessary?
| Cron job triggered - But expect echo nothing is working |
1,396,342,628,000 |
I have a machine configured (via cron) to start a screen session on reboot. The session opens up a few screens and starts a server in one of them. All of this works fine. However, when I login and resume the screen session, I get a (PS1) prompt like this:
\u@\h [\j] \w\$
Terminal colors do not appear either. This is... |
The fact that magic characters like \w in PS1 are not being interpreted seems to suggest that the shell started by screen is not bash, but something simple like /bin/sh. I looked at /etc/crontab in one of the systems I had to hand and it had the line
SHELL=/bin/sh
at the start, but another distribution had SHELL=/bin... | How to start screen on reboot with an interactive TERM/TTY |
1,396,342,628,000 |
i have written a script in python3 that gets me some magnet links, the script works perfectly, but i want it to run periodically so i created a cron job to do it every other day.
While testing it i get the error that xdg-open: no method available for opening 'magnet....'
i have already checked that my default browser ... |
i just found the solution,
i was using a bash file to start the python3 virtual environment, and run the script.
i added at the beginning of the file 2 environment variables
export BROWSER=/usr/bin/firefox
export DISPLAY=:0
that fixed the issue
| xdg-open: no method available for opening -- Crontab |
1,396,342,628,000 |
I am making backups of all databases of MySQL into separate gnu-zip files using crontab. I also want to delete backup files older then 1 day.
I am using below command to delete the old files, but it only works through terminal. If I set cronjob for same command then it does not work. I don't know what is wrong. Going ... |
According to what you are showing in the question and saying in comments, your script is not executable and does not contain a #!-line.
At a bare minimum, you should make the script executable with
chmod +x /path/auto_delete_backup_database.sh
and give it a proper #!-line:
#!/bin/sh
(this needs to be the very first ... | can't delete files older then x days through cronjob |
1,396,342,628,000 |
I have this user who have a lot of cron jobs and I expected it to log stderr in its /var/mail/user. Sample below cron entry is working as expected in a different server.
* 30 * * * * /usr/local/bin/scripts/test.sh > /dev/null 2>&1
I've compared postfix/main.cf on both servers and cannot find anything different. Is th... |
This is an explicit redirection in the cron command: > /dev/null 2>&1. It means both stdout and stderr are thrown away. There's no basis to expect any mail then. To keep stderr, leave just this redirection at the end: >/dev/null.
| Cron is not logging stderr in /var/mail/user |
1,396,342,628,000 |
Yes, I know C-shell is bad. No, I did not choose C-shell. Yes, I would prefer to use a proper shell. No, I cannot switch to a better shell.
I have a very simplistic script:
/tmp/env_test.csh
#!/bin/csh -f
env
When I run this script from my user that is logged in with a tcsh shell, SHELL equals /bin/tcsh. When I ... |
Look into man 1 csh. The section Pre-defined and environment variables lists which variables csh defines or respects. There is a variable shell in lowercase:
shell The file in which the shell resides. This variable is used in
forking shells to interpret files that have execute bits set,
... | Why is SHELL pointed to /bin/sh in a Csh script? |
1,396,342,628,000 |
I have a computer periodically syncing folders of content with another computer using Resilio Sync. The receiving computer has a sorting process on an hourly cron, which analyses the folders and their contents before moving & cataloging them in a seperate filesystem.
My issue is the hourly cron will run and process fo... |
I suspect there are many ways to do this. The first that came to me to to include a checksum. On the sending server you can run:
tar -cf - FILES | md5sum > my_sum.md5
Where we use tar to create (c) a file (f) onto stdin (-) from FILES which can be a glob, directory, or space delineated list of files which then gets p... | How do I confirm a file sync has completed before executing a command? |
1,396,342,628,000 |
I've got a server that is used as an SFTP endpoint and a script living somewhere else that periodically uploads to the server.
At a particular time every day all the files in the upload folder get the string 'archive_' prepended to their names.
How can I go about tracking down the culprit name changing script?
I've... |
Solved. The script that was pulling the files from the server was adding the text string to the file names to flag them as files that don't need to be pulled the next time around.
Thanks everyone!
| Finding a rogue script changing filenames? |
1,396,342,628,000 |
I'm trying to build a script that automatically takes a file on the remote server and replace with crontab file, but I get permission denied.
My idea is to create a shell function for it:
update_crontab() {
SSH_HOST=$1
FOLDER=$2
{
if ssh -o "BatchMode yes" $SSH_SUDO_WHITOUT_PASS@$SSH_HOST "[ -f $FOLDER/cron... |
Since both files are remote, you can simply:
ssh ... "sudo cp $FOLDER/crontab /etc/crontab"
... which avoids the "sudo redirection" problem where only the cat has elevated privileges, and your normal user shell does the > /etc/crontab redirection.
| Remote overwrite crontab file with sudo |
1,549,401,462,000 |
I have this script to change the background and screensaver from my gnome desktop. Works fine when executing manually, but when I put it in cron it doesn't execute it. The file is executable.
I added the cron job with crontab -e.
This is the script:
#!/bin/bash
# change_background - Change desktop background and lock... |
The issue seems to have been that the environment in the crontab was not set up with a correct PATH, so the script was never found. The user's shell initialisation files are not run by cron, so setting the PATH or other variables therein is useless for a cron job.
This can be solved in a number of ways.
One is to sim... | Crontab not executing script that change background |
1,549,401,462,000 |
Background
The PNG image files I want to use is stored in directories according to date, for example:
/NAS-mein/data/201812/
PNG stored within it like /NAS-mein/data/201812/foo/bar/20181231_1500.png
So I created a symbolic link PNG_path in my home directory
ln -s /NAS-mein/data/201812/ PNG_path
and I'm able to upda... |
The percent sign is special in crontab and needs to be escaped if you put your date command there (see man 5 crontab).
Your symbolic link points to a directory. When you run ln again, it will put the link inside that directory.
Example:
$ mkdir real
$ ln -sf real link
$ tree
.
|-- link -> real
`-- real
1 directory, ... | How to regularly update symbolic link (ln -sf) via crontab |
1,549,401,462,000 |
Till now I organized my non-crontab cron-jobs by cron.d in Debian-LAMP environment.
My cron-jobs use me to upgrade CMSs containing my web applications.
Here's how I do it from the beginning:
#!/bin/bash
cat <<-EOF > /etc/cron.daily/cron_daily
#!/bin/bash
for dir in ${drt}/*/; do
if pushd "$dir"; then
... |
The /etc/cron.daily will be available after installing cronie package, it is not pre-installed:
pacman -S cronie
The default system scheduled jobs in arch linux is managed through systemd.timer. To list the timer units :
systemctl list-timers
| Using cron.d in Arch |
1,549,401,462,000 |
I have a bash script named testScript.sh that looks like this :
#!/bin/bash
curl -X GET https://www.example.com -o ~/Desktop/testFile.json
curl -X POST -d ~/Desktop/testFile.json http://www.example2.com
i want to run this script with crontab so i edited crontab file with crontab -e command like that :
* * * * * ~/De... |
The answer to my problem was given out by @meuh
If you want curl to send the contents of a file, and not just the filename, you would need -d @filename but tilde ~ will not be expanded so use -d @$HOME/Desktop/testFile.json
| Cron - crontab executes half of bash script |
1,549,401,462,000 |
Content of service crond status -l:
[root@test ~]# service crond status -l
Redirecting to /bin/systemctl status -l crond.service
● crond.service - Command Scheduler
Loaded: loaded (/usr/lib/systemd/system/crond.service; enabled; vendor
preset: enabled)
Active: active (running) since Mon 2018-01-15 13:34:58 EST; 1 mo... |
cronie (the cron in question), does a specific check for file permissions on each crontab file, at:
https://github.com/cronie-crond/cronie/blob/master/src/database.c#L96
The mask it uses is 533 and the resulting masked permissions must be 400, which means that it will allow read (4) or read/write (4+2) bits for the ow... | BAD FILE MODE yum-cron |
1,549,401,462,000 |
I have a Ubuntu 16.04 Nginx environment with a few minimal WordPress sites (virtually all with up to 5 conventional plugins, 10 pages, 10 images, and a simple contact form to send only textual data).
I daily execute the script cron_daily.sh with the following three loops, from crontab, to update all WordPress apps und... |
Why three times the same loop instead of one loop like in your example?
At first glance I don't see how this could get any shorter — nor why it should.
If anything, the script could get better (and thus longer) by improving the detection of WordPress (if needed). Also, I'd probably run wp language core update as well ... | Shortest way to automatically upgrade all WordPress instaces under document root (>=4.7.x) |
1,549,401,462,000 |
I have a script which runs perfectly in terminal, but when I tried to run that in crontab every "5 minutes", I got following errors in /var/log/messages:
crond: sendmail: fatal: parameter inet_interface: no local interface found for ::1
Crontab entry:
*/5 * * * * /bin/python /scripts/python/account.py >> /script/pyth... |
Here's what resolved my problem
I updated /etc/postfix/main.cf file as:
comment out: inet_interfaces: all
add inet_protocol: ipv4
Now I am not getting any sendmail error at all in /var/log/messages.
| crond: sendmail error while running a python script in crontab |
1,549,401,462,000 |
My Solaris 11 cron appears to have stopped working.
Here is the last output of a cron job I run:
-rw-r--r-- 1 root root 60 Jul 2 20:30 locked_passwords.txt
I setup a test, like this:
* * * * * touch /tmp/testing.txt
It never touches the file
I checked if the service is running:
svcs cron
STATE ... |
Have you checked /var/cron/log?
Perhaps the account is locked or added to cron.deny?
Is there a corresponding .au file in /var/spool/cron/crontabs? Historically, that file was needed for jobs to run. Since it's created by crontab -e, it's usually only missing if a cron file was copied to a new server.
Possible issue... | Why has cron stopped processing commands? [duplicate] |
1,549,401,462,000 |
Cron:
1-59 * * * * orangepi /home/orangepi/message.sh > /dev/pts/4;
message.sh:
#!/bin/bash
echo -e "\033[37;1;41m WARNING \033[0m"
After executing I need press enter that return to console(root@orangepi:/home/orangepi#).
|
You have opened /dev/pts/4 for writing, and wrote the output of echo into it, nothing more than that. There is no execution/interpretation of the echo command by your shell, so your shell does not display a new prompt.
If you want to execute a command from one terminal to another, you can try non-standard tools such a... | how to disable waiting "press enter" after executing bash script over cron |
1,549,401,462,000 |
My Oracle Linux 6 system date prints:
$ date Sat Mar 18 08:05:10 PDT 2017
And /var/log/cron timestamp prints:
Mar 18 15:05:04
Why is it different, where can I make the change (is there any conf file), so that cron log prints the log in same timezone as system?
|
The issue was resolved by running the following:
/etc/init.d/rsyslog restart
/etc/init.d/crond restart
| Why oracle linux system's /var/log/cron timezone different from system date? [closed] |
1,549,401,462,000 |
I am backing up my notebook running Arch and my girlfriend's MacBook regularly using rsync and cron / launchctl via ssh.
The target is a FreeNAS server.
I would like to monitor whether the automatic jobs are running correctly, by receiving a notification if the content of the backup folders did not change for a certai... |
The content of the backup not changing as a symptom of the backup not running? In that case monitor the cronjob with a dedicated cron monitor such as WDT.io. This recipe's example is specifically about backups and shows you how to do it.
| Monitoring last rsync backup |
1,549,401,462,000 |
I made a script where the first step is to check if a Mac is even online (otherwise it would be unnecessary to even start the script). In the terminal it works perfectly fine: everything runs as it is supposed to.
I want to run it via a cron job at 23:30 at night, so I created a cron job and logged the whole thing. T... |
You need to set an explicit PATH for a script to be run under cron. The default is PATH=/usr/bin:bin and you need (at least) /sbin there.
#!/bin/bash
export PATH=/usr/local/bin/:/usr/bin:/bin:/usr/sbin:/sbin
...
You could also consider tweaking the options on the ping test slightly. The -o allows ping to exit as soon... | Crontab can't reach several Macs? |
1,549,401,462,000 |
I've been looking around but haven't found a solution to my particular problem.
I need to create a cron job to backup a file system on daily basis. But the application needs the current date/time to run.
Example:
bundle exec thor migrator:export /var/tmp/backups --after "2016-12-22 00:00:00 -0700"
How can I easily ru... |
Assuming the following line is your example.
bundle exec thor migrator:export /var/tmp/backups --after "2016-12-22 00:00:00 -0700"
You could use a command substitution for this job.
bundle exec thor migrator:export /var/tmp/backups --after "$(date --iso) 00:00:00 -0700"
But I rather would recommend to put your comm... | Cron job with a dynamic date |
1,549,401,462,000 |
I am making a GFFS backup script for a school assignment but I've encountered some issues with it. It works like this:
/etc/backup/backup.sh PERIOD NUMBER
I have added the following lines in cron:
# m h dom mon dow command
# Backup for fileserver:
#daily: 5 times/week
0 23 * * 1-5 /etc/backup/backup.s... |
I think you have to escape the "%"- signs
so this:
0 23 * * 1-5 /etc/backup/backup.sh daily $(date -d "-1 day" +\%w)
... should work.
I dont know which have to be escaped, it think + and %, please try out.
*when I did it in cron I used the uglyer backtick-syntax for command execution and had to escapte the... | Script working manually but not in cron - not calculating var? [duplicate] |
1,549,401,462,000 |
I have the shell script which opens Firefox and launches macros in it (I use a Firefox add-on called Imacros to create macros). The content of my shell script named house.sh is like that:
firefox imacros://run/?m=house.iim
And I created a scheduled job via crontab -e to run that script hourly every day:
47 * * * * /... |
You should be able to get this to run by putting in house.sh:
export DISPLAY=:0.0
and running xhost + on your interface. Once that works you can restrict who is allowed to connect (using xhost again), but once things stop working you'll know how permissive you have to be.
This will not work if you are not logged in. ... | How to schedule run shell script that opens Firefox [duplicate] |
1,549,401,462,000 |
This question is related to Debian 8.4.
I applied the same updating mechanism to several desktop stations and one unused server. This problem appeared on the server, but I suspect it will happen on all those stations too.
As solved in this thread, I managed to get the cron job logged, now I waited for an update. Here ... |
cron typically runs things in a fairly minimal environment (man 5 crontab to see what exactly), which probably doesn't have enough in its path for this. If you want to see what is in the path, you can always run printenv > /tmp/cron_env from (presumably at a time in the near future) to see. Generally, you can just d... | CRON problem - an apt-get dist-upgrade job |
1,549,401,462,000 |
I'm having troubles with my crontable on the scientific cluster I'm using. It's a bit peculiar, since the jobs seem to run (I get regular mails from some updates) but when I type
crontab -l
the response is:
> no crontab for USER
Same story for
crontab -e
where I end up with an unedited file, somewhere in the t... |
First of all, there is good possibility that mails are coming from somewhere else, so you need to make sure where did it come from. Inspect mail headers, particularly Received: headers. It will show you that info.
| Cronjob running but no crontab for user? |
1,549,401,462,000 |
I'm getting ready to launch a crontab, but since I'm new at it, wanted to check with someone if they could verify that what I'm doing is correct.
* 3 * * 5 /usr/local/bin/backup.bash
The above crontab line will run my backup bash file EVERY Friday at 3 a.m., is that correct? I need it to run every Friday, not just on... |
You need to add 00 (or 0) to the minute(s) field, otherwise it will be run for each minute from 03:00 to 03:59 on every friday.
So, to run the job at 03:00 AM every friday:
00 03 * * 5 /usr/local/bin/backup.bash
| Crontab Line Date |
1,549,401,462,000 |
With the root user I configured the JAVA_HOME variable for crontab like this:
[root@localhost ~]# vim /etc/crontab
_______
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/opt/jdk1.8.0_71/bin
MAILTO=root
JAVA_HOME=/opt/jdk1.8.0_71
_______
I have defined a cronjob run by a different user named tomcat like this:
[to... |
I got it working this way:
Insert the following line in the file /opt/tomcat/bin/setenv.sh:
export JAVA_HOME="/opt/jdk1.8.0_71"
| CentOs 7 CronTab set JAVA_HOME |
1,549,401,462,000 |
I have a PHP script I'm running from Cron. I want to save its output to file, but also want to save the shell output to a different file. Ideally, I'd like to have this in one line. As such, I tried the following:
script "/folder/log/file.errors."`date +"%Y-%m-%d.%H-%M-%S"`".txt" && /usr/bin/php /folder/file.php > "/f... |
Per terdon's request, I am posting this comment as an answer, so that the question can be marked as "answered"
Instead of relying on script logging, especially if this will
eventually be a cron job, consider sending output and error messages
to one or more designated files(s) in your php code. When you run it
i... | script Multiple Commands |
1,549,401,462,000 |
I'm trying to write a script that will identify corrupt jpg images using imagemagicks identify command. The script will run the command, grep the output for the word "Corrupt", move it to a corrupt folder if corrupt or move it to an input folder if the file appears good.
My script works as expected if I run it manual... |
I suggest to replace your if block by:
/opt/ImageMagick/bin/identify -verbose "$f" | /usr/bin/grep -iq "Corrupt"
if [[ ${PIPESTATUS[0]} -eq 0 && ${PIPESTATUS[1]} -eq 1 ]]; then
mv "$f" "$INPUT_FOLDER"
else
mv "$f" "$CORRUPT_FOLDER"
fi
From man bash:
PIPESTATUS: An array variable (see Arrays below) contai... | script not running as expected when scheduled as a cronjob |
1,549,401,462,000 |
I run a script file through CRON daily which involves running selenium testcases and sending the report as mail. Here is my script: check.sh
#!/bin/sh
set -x
./.bashrc
export CLASSPATH=/home/test/TestAutomation/lib/*:.
cd /home/test/TestAutomation/lib/
/usr/bin/java -jar selenium-server.jar &
cd
javac Api.java
java A... |
By placing export CLASSPATH=/home/test/TestAutomation/lib/*:. above if condition solves the problem. Thanks everyone for the comments.
| Java file is not getting compiled in cron |
1,549,401,462,000 |
I want to automatically delete old files in ~/Downloads.
with exception of ones that have '!' in their name.
My current version is as follows:
find /home/user/Downloads/ -mtime +90 ! -path '*!*' -delete
When I test it as follows*:
find /home/user/Downloads/ -depth -mtime +90 ! -path '*!*' -print
The result is:
/home... |
If all you want to do is protect the path given to find from being deleted, use -mindepth 1. I'd split the action, however: run once, deleting only files, and run again, this time deleting directories using rmdir, which will only remove empty directories. Note that deleting a file should change the access and modify t... | Cleaning script with find and anacron |
1,549,401,462,000 |
I've done a little java program that ends showing a dialog after doing some other tasks like reading from a web and writting on a file.
My goal is to make it run everytime my system starts with 90 seconds delay. (@reboot sleep 90; ...).
It allready does all the job well (it creates the file that I want correctly), but... |
I assumed that cron was the only way to achieve my goal, but I was wrong because cron is for starting background jobs. Then I tried to create a .desktop file and adding it to Startup Applications and it worked.
The file is in ~/.config/autostart and this is what it contains:
[Desktop Entry]
Type=Application
Name=Compr... | How to show Java dialog when cron runs the Java program? |
1,549,401,462,000 |
I want to start a process in a terminal using cron. I want the process to start in a terminal, so that I can continuously see the output of the process on the terminal, and kill it / restart it etc. I know I can do this via screen, by using "screen -p -X stuff ", but I've lately run into weird issues with screen free... |
Here is a solution which will both unlockpt() a new pty descriptor and write its ptsname() to stdout for you.
<<\C cc -xc - -o pts
#include <stdio.h>
int main(int argc, char *argv[]) {
if(unlockpt(0)) return 2;
char *ptsname(int fd);
printf("%s\n",ptsname(0));
return argc - 1;
}
C
Whic... | Using cron to start a process on a terminal without using screen? |
1,549,401,462,000 |
Let's suppose we have a crontab scheduling some commands on an RPi project, and these commands toggle a status of a flag. The box could go out of power, and then reboot. I want to have the flag status at the correct state if the box was continuously working.
My Idea:
Having a task on the reboot that:
recovers the las... |
Apparently it is not an out of the box task. I found a library in python:
https://pypi.python.org/pypi/python-crontab
that allow to find a "schedule" for a single job:
schedule = job.schedule(date_from=datetime.now())
...
datetime = schedule.get_next()
That is exactly the needing. Looping from date_from last reboot d... | Getting crontab events that would happen given a start date/time |
1,425,987,254,000 |
I have issue with my crontab - cron is not launching one of my scripts
this is top part of my crontab (root)
SHELL=/bin/bash
#---------------------------------------
# Items availability
#---------------------------------------
# Daily offer import + daily sync everything
30 7 * * * /var/www/import/download_... |
it magically works again
only thing i changed was
30 7 * * * /var/www/import/download_offers.sh > /var/logs/download_offers_cron.log
^^ here
to
30 7 * * * /var/www/import/download_offers.sh > /var/log/download_offers_cron.log
... | crontab not launching one script |
1,425,987,254,000 |
I've got a cronjob that looks like this
0 0 * * 7 [ $(date +\%d) -le 07 ] && /home/archiver/archiver.sh &> /home/archiver/output
And it works from the cron+bash perspective in that it'll run on the first Sunday of every month (or so I assume. It ran today, but we'll see about next Sunday, haha).
But the &> /home/arch... |
Your cron seems not to know or use the &> shortings from bash. When you write the redirection like this
/home/archiver/archiver.sh >/home/archiver/output 2>&1
it should work.I would prefer >>/home/archiver/output 2>&1 to always append to the logfile, too.
| cron: output of a script? |
1,425,987,254,000 |
Is there a good reason why apt-get remove leaves installed cron files in place where an apt-get purge or apt-get remove --purge is actually required to completely remove them?
Example files may be:
/etc/cron.d/<packagename>, or
/etc/cron.hourly/<packagename>
The man pages and everything else I've seen seems to ind... |
Yes, those files are considered configuration files. Generally, (at least) everything in /etc is considered a configuration file in Debian. That's why it takes a purge to remove them. The reason they are configured configuration files is that anything that the system administrator is reasonably expected to customize o... | Why does apt-get remove leave package-installed cron files lying around? |
1,425,987,254,000 |
I have a crontab job to sync a folder:
50 5 * * * /home/user/bin/sync-folder
This will execute an script:
#!/bin/bash
sudo rsync -rav --delete --log-file=/tmp/rsync-output /origin /destination
grep folder /tmp/rsync-output
if [ $? == 0 ]; then
cat /tmp/rsync-output
fi
The issue is that when there is nothing to... |
Replace this:
50 5 * * * /home/user/bin/sync-folder
With this:
50 5 * * * /home/user/bin/sync-folder > /dev/null 2>&1
Add email inside script:
#!/bin/bash
sudo rsync -rav --delete --log-file=/tmp/rsync-output /origin /destination
grep folder /tmp/rsync-output
if [ $? == 0 ]; then
mailx -s "Rsync Complete at `d... | Prevent empty rsync email on cron |
1,425,987,254,000 |
I have a server with some OpenVPN instances (one server, several clients) running on Debian with enforcing SELinux. The connections to some of the VPN servers my machine is connecting to are somewhat unstable, and the OpenVPN instances on my machine crash now and then, so I had set up a cronjob to restart them in case... |
The first error is clear; the line you've commented out gives the permission that audit says is missing.
The second part is more interesting, but what I suspect is the problem is the target context of the socket you're modifying (owned by unconfined_u). Because you've moved to static device nodes, your interfaces are ... | Restarting OpenVPN on SELinux by a cronjob |
1,425,987,254,000 |
I want to stop dropbox from running as soon as I log into my account. Now I know I could do this simply by going to Startup Applications and disabling dropbox. But I was wondering if there is a cron-ish way of doing it or is cron not supposed to be used for stuff like these?
Currently I have this in my crontab
@reboot... |
The @reboot entry is there for doing things after each reboot. That is not what you want.
Cron is not the right tool for this, as it starts something at a specific time and it has no clue about you being logged in or being in the process of logged in. At most a cron job run every minute could look if you are logged in... | Killing a process with cron as soon as it starts |
1,425,987,254,000 |
I have been trying to create a cron job to execute a script located in ~/Documents/script.sh at midnight every night and every 8 hours after that.
I have found a lot of material on this but for some it doesn't work.
This is what I have:
* 0 * * * ~/Documents/script.sh
0 */8 * * * ~/Documents/script.sh
|
There is no tilde expansion in your cron job, you have to put in something like:
0 */8 * * * /home/yourloginname/Documents/script.sh
This will run script.sh (assuming it is executable (chmod +x script.sh)), at midnight, 8 AM and 4 PM.
Leave out the first line you indicated, that would run the script every minute be... | Cron Job Not working [closed] |
1,425,987,254,000 |
I use cron for years now. In order to load all my environment variables at once, I define them in a dedicated file (often but not always .bashrc) that I source in the crontab:
* * * * * (. /home/me/my_environment_variables.sh; my_script.sh)
Unfortunately, this trick fails to work with the debian wheezy server I've b... |
. is an internal shell command. Check what shell is used by cron (by default it is /bin/sh).
Alternative solution is to create a wrapper script and put these commands inside. It will work for sure.
| Why can I not source a file with the default cron installed on a debian wheezy server? [closed] |
1,425,987,254,000 |
I have a very simple bash script that runs flawlessly when I do
./removeOldBackup.sh
or
sh /home/myusername/backup/removeOldBackup.sh
but when I add it to crontab like
* * * * * sh /home/myusername/backup/removeOldBackup.sh
or
* * * * * /bin/sh /home/myusername/backup/removeOldBackup.sh
it never works...
This is... |
To formalise and expand on what someone said in a comment, when you put something in root's crontab it will run inside /root, not in the directory the script is in, because cron doesn't even know where that is. Because your backup files aren't in that directory tree, the find command never reaches them. So the job is ... | bash script not being run by cron [duplicate] |
1,425,987,254,000 |
I'm on VMWare which, no matter what anyone says, responds to most unix commands.
Some things are unique though, for example the fact that almost no files are persistent through reboot. Due to this I'm getting a problem with a scripted backup which is using a variable to name log files:
If I manually insert
backup-$(da... |
The dollar sign in your string is being expanded at the time the echo is run and causing command substitution to happen then. What you want is to pass that string AS A STRING on to the file. There are two ways you can keep the substitution from happening.
You can escape the dollar sign:
/bin/echo "0 0 * * 1-5 ../..b... | Insert variable and keep the variable |
1,425,987,254,000 |
As nonroot user, how can I schedule a reboot every day at 4:30am?
30 04 * * * /home/user/scripts/reboot.sh
As a nonroot normal user, I'm sure the system won't allow me to use the reboot command.
What settings do I need to change in Debian order to make this scheduled reboot work? (without asking for sudo password)
|
You need to put your cron entry in /etc/cron.d or /etc/crontab for it to be run as root. If you put it in a new file under /etc/cron.d, that format should work (/etc/crontab uses a slightly different format).
| Debian, nonroot, cron, bash script and rebooting at specific time |
1,425,987,254,000 |
I have set up a cron job on my local Ubuntu 12.04 server to log on a remote server through a passwordless ssh connection and run mysqldump on a database on that server once a day. My problem is that, in addition to running mysqldump at 00:00 every day, it is for some reason also run at HH:17 at every hour, thereby fil... |
Although I'm running a different version of ubuntu, my /etc/crontab runs the hourly script 17mins past the hour.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# m h dom mon dow user command
17 * * * * root cd / && run-parts --report /etc/cron.hourly
25 6 * * * root te... | cron runs job at unexpected times |
1,425,987,254,000 |
I'm running Arch ARM on a PogoPlug and want to execute a file every hour, the file when call directly runs fine (it is executable), for testing the file
/etc/cron.hourly/crontest
contains
#!/bin/bash
date >> /root/log
First I copied it to /etc/cron.daily but it wouldn't run, run-parts --test lists it as valid but no... |
You need to make sure cronie is started. You can do so with the following command:
systemctl start cronie
This command will enable cronie to start on boot:
systemctl enable cronie
| Neither crontab nor anacron is running, how to debug? |
1,425,987,254,000 |
I am creating this cron as apache user and want to run this cron as root, below is my code snippet:
# Create a cron job to restart apache
cron_file="/etc/cron.d/restart_apache_crontab"
cron_job="*/1 * * * * root condrestart-apache.sh"
echo "$cron_job" > $cron_file
chmod 777 $cron_file
exit 0
Provided sufficient priv... |
In the cronjob "*/1 * * * * root condrestart-apache.sh" I would expect an absolute path to your restart script e.g. /usr/local/sbin/condrestart-apache.sh.
And condrestart-apache.sh must be an executable (e.g. chmod 755) shell script and of course include something like #!/bin/sh which is missing from your snippet.
T... | Create cron as a apache user and run as root user |
1,425,987,254,000 |
I'm having a strange case of deadlock, where the two processes launched by cron are defunct, but cron does not pick the return code and exit. I don't have access to the root user.
myuser@myserver:~) ps -ef | grep 30163 11:29AM
3701 28964 29950 0 11:30 pts/13 00:00:00 grep 30163
... |
The Last SLES11 SP1 kernel when EoL came (2012-11-08) was 2.6.32.59-0.7.
Kernel 2.6.32.23-0.3.1 is from 2010-10-08.
So you are most propably hitting an unfixed OS bug.
Wake up your root-admin and tell him to get his system in shape.
Current supported SLES11 is SP2. Kernel: 3.0.80...
To your second part of the question... | Deadlock in a crontab between cron and its child defunct processes |
1,425,987,254,000 |
I want to create a cronjob at my Ubuntu server by adding/modifying a file in the /etc/cron.d folder, rather than using crontab -e as it's not too easy to automate.
I've managed to make a file looking like this:
* * * * * username command >> logfile
I can tell that the file is there, I've chmoded it to 777 but it stil... |
The file needs to be owned and writeable by root. Also make sure that your time-specification is correct - is * * * * * the real one?
| Setting up a cronjob as a file |
1,425,987,254,000 |
Basically I have a bash script that fetches data from my server to perform a backup.
As it is now I have to start that script manually, enter the password, and then wait for it to finish.
I would like to set up a cronjob that handles the backup.
But I really don't know how to handle the password in a cronjob.
Also I c... |
This is the command I use to backup to another machine:
rsync -av -e "ssh -i /root/ssh-rsync-valhalla-key" \
--exclude lost+found \
--delete-before \
/mnt/backup/ \
[email protected]:/cygdrive/r/\!Backups/Niflheim &
So you can use the -i to pass a keyfile to ssh. Of course, in your example, that means the key... | Using rsync in a cronjob when a password is needed |
1,425,987,254,000 |
I wanted to remove unnecessary logs automatically , like Xorg.log.0 , and other packed *.gz files , i really don't need that on a laptop system.
However , i checked man logrotate , but only an entry called shred , but irrelevant.
|
Removing old logs is the main job of logrotate. The number of old log versions kept on your disk is set by the rotate config option.
Also, take a look at the configuration files (/etc/logrotate.conf and /etc/logrotate.d/*) as well as man logrotate to see various ways how the rotation can be triggered (like monthly o... | How to remove obsoleted logs with logrotate? |
1,425,987,254,000 |
I have installed crontab on CentOS 5.6 x64 via
yum install vixie-cron.x86_64
Here is my crontab -e
SHELL=/bin/sh
0 0 * * * cat /root/mysql-backup.txt | xargs /root/mysql-cron.sh
Whenever I run this command manually it executes without problems:
cat /root/mysql-backup.txt | xargs /root/my... |
As an answer this question Stéphane Gimenez told me to run crond. Here is how to do it:
/etc/init.d/crond start
| vixie-cron.x86_64 doesn't seem to execute jobs on crontab |
1,425,987,254,000 |
If I (e.g.: under Fedora) edit the crontab file with vim, then I restart crond:
/etc/init.d/crond restart
then the actual crontab file: "/etc/crontab" is the same as the actual cronjobs in reality. Ok!
But:
Q: How could I list the real-actual cronjobs, if the "/etc/crontab" file gets modified, but the crond not relo... |
All the implementations of cron that I know of re-read /etc/crontab every minute, i.e. as often as they execute jobs. So the “real-actual” cron jobs are the ones in the crontab file.
There are (or were) a few buggy implementations of cron that check for jobs to execute first and only then check the crontabs. This caus... | How to list the actual cronjobs? |
1,425,987,254,000 |
I have this /etc/cron.d/reboot file:
PROJECT_ROOT=/usr/local/share/applications/ana
NODE_PATH=/usr/bin/node
REBOOT_SCRIPT=/usr/sbin/reboot
SCRIPT=scripts/server-reload-messages.js
0 5 * * * root cd $PROJECT_ROOT && $NODE_PATH $SCRIPT create
1 5 * * * root $REBOOT_SCRIPT
I need the script to work once a day at 5am,... |
The correct answer was in the comments from user bxm . The matter is that the time zone of the server for 12 hours differs from the time zone expected by me.
| Cron works at 5pm instead of 5am |
1,425,987,254,000 |
I am trying to copy a file on reboot as raspberry pi deletes my .asoundrc file every time. I have a copy of the file saved and a shell script I wrote. The shell script works, but I cannot get it to run in crontab. According to
Code in script named copyASoundRC.sh
#!/bin/bash
cp '/home/sox/asound data/.asoundrc' '/home... |
It appears you may have mangled your script, and your crontab entry...
why do you have a space between asound and data in cp '/home/sox/asound data/.asoundrc' '/home/sox'??
why do you have a back-slash in the crontab entry??
where exactly is the folder you refer to as data??
Assuming the folder data is actually loca... | How to copy a file from one directory to another through crontab's reboot |
1,674,226,105,000 |
sudo Crontab -e
15 0 * * 1-5 /usr/bin/screen -S wake_up -d -m /home/pi/auto/wake_up.py
But at 00:15 there is no screen started...
This command: (worked in terminal)
screen -S wake_up -d -m /home/pi/auto/wake_up.py
Python File:
#!/usr/bin/env python3
import time
x = 1
while x<10:
print (x)
x += 1
time.sleep(1)
... |
screen -S wake_up -d -m /home/pi/auto/wake_up.py
This will not keep a command screen open. Instead create this file:
% cat /home/pi/auto/.boot-screenrc
screen -t cpu 1
stuff /home/pi/auto/wake_up.py\015
This starts a screen, inserts (stuffs) the python command into the stdin, and adds a return.
Then add:
screen -d ... | How to start a screen with crontab |
1,674,226,105,000 |
I have CentOS 7 and am trying to access a configuration file that looks a little something like this:
# Cron configuration options
# For quick reference, the currently available log levels are:
# 0 no logging (errors are logged regardless)
# 1 log start of jobs
# 2 log end of jobs
# 4 log jobs with ex... |
CentOS/RHEL 7 use the cronie implementation of cron. The file you show there relates to vixie cron, as used on distributions such as Debian.
[root@centos7 ~]# head -2 /usr/share/doc/cron*/README
17. January 2008 mmaslano (at) redhat (dot) com
Rename the fork on cronie. The source code could be found here:
[roo... | Can't find cron config file |
1,674,226,105,000 |
I have a cron job that executes an R script hourly.
The script checks an online data source that gets updated at an unknown time each day.
If the data source is not updated, the script exits with an error code.
If the source is updated, the script runs normally without any error codes.
After the script completes, I n... |
Add something like the following to the end of your cron job's command line:
&& date | sendmail -s "R job completed successfully" [email protected]
That will email you an alert on success, and non-zero exit codes will be handled normally by cron.
The date is a placeholder for echo, printf, cat, or whatever you want t... | Crontab notify after successful execution? |
1,674,226,105,000 |
I'm working on RHEL 7.9.
In my crontab, I have the following variables and command :
MAILTO=""
SHELL="/usr/bion/ksh"
30 * * * * find /home/me/data/input -name "*.completed" -size +10M -print >> /home/me/jobs/completed.big 2>/home/me/jobs/completed.big.errors
Since everyone has detected the extra o in the SHELL var, ... |
According to this reference, the cron daemon has options for this:
-s -m off
Man pages do reference those args:
-s sends output to system log (usually something like /var/log/cron)
-m off disables sending mails
It is done system-wide, but it fits my needs:
Corporate root jobs are quiet (inventory, patches)
Mine are... | Trapping all crond errors in logs rather than email |
1,674,226,105,000 |
I have a cron job that locks the computer using i3lock at a certain time (12:15), but sometimes I put the computer to sleep before 12:15. If I then I wake up the computer after 12:15 (usually around 13:30), the computer gets locked immediately after wake-up. Why is that?
My OS is Debian buster x86-64.
|
I know about anacron, but as I check its configuration, anacron is clearly not responsible for the immediately sleep after wake up. I read the manual about cron, and found out
Special considerations exist when the clock is changed by less
than 3 hours, for example at the beginning and end of daylight savings
tim... | why debian run cron scheduled task immediately after wake up from sleep? |
1,674,226,105,000 |
I'm trying to schedule a cron job and I'm failing soundly. I'm even starting to think that this can't be done with cron.
I'm trying to set a job that will run at a certain hour every day for six months. Then it should stop for two months and start running again for six months, after which it will stop for two months, ... |
There’s no way to fully express your conditions using cron, however it is possible to supplement cron by adding a condition which is evaluated by the shell. The idea here is to tell cron to run your job every day at the appropriate time, then before starting the job, use the shell to check the month.
For example, assu... | Daily cron jobs active or inactive for periods of months |
1,674,226,105,000 |
I'm working on a python script, I created a file in /var/log/ folder with 664 permissions
python script is not able to write logs to the file created, IDK why... since file owner is ubuntu(aws's default user).
very carefully I have given Read and Write permission to the file
scheduled crontab failed to run the app bec... |
If you run
ll -d /var/log
Then you'll see that it is owned by root (possibly with syslog as the group) and has 755 or 775 permissions which means that while others can read and traverse the directory, only root (and possibly syslog) can modify it. ice-message-initiator.log is in /var/log and while ubuntu is its owne... | Owner not able to write log file |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.