Tag Info

Hot answers tagged

4

I don't think you can use environment variables, as they won't persist between script "runs". Alternatively, you could write to a temporary file in /tmp or somewhere in your home directory, then check it each time? For example, something like #!/bin/sh output=$(wget http://lon2315:8081 2>&1) pattern="connected" tempfile='/tmp/my_website_is_down' ...


4

cron by itself doesn't support this. The eariest way to accomplish what you want is probably to ask cron to execute a dispatcher script every day (at the same time) and have the dispatcher script decide which other script to run based on what day it is. For example: #!/bin/sh case $(expr $(date +%s) / 86400 % 5) in 0) exec /script/for/day/1 ...


4

Using just 56 on the first field you are telling cron you want to run the script at minute 56; while setting "*/56" on the first field you are telling crontab to run the script every 56 minutes. If You want the script to run at 12:56PM, 01:56PM, 02:56PM ...; then you use 56 56 * * * * /usr/bin/python3 /home/asd/asd.py


3

Have you looked at this? I think what you are looking for is: 5-59/15 * * * * /root/job.sh >> /root/job.log


2

Items in crontab execute with a limited environment. At the top of your script you can specify your PATH, for example, PATH=$PATH:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin or alternatively you can call each executable with its absolute path.


2

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.


2

No need to use a for-loop here, you can just use find: sudo find /var/log/ -type f -regex '.*\.[0-9]+\.gz$' -delete However, as suggested, check the manual page of logrotate for ways to reduce the number of files.


2

Often times when applications are being killed, it is always a good idea to take a quick look at your /var/log/messages file to see if the kernel is killing the process. The most common trigger (in my experience) has always been due to out-of-memory (OOM) errors, since my company primarily uses java applications, it is quite common for the devs to publish a ...


2

Few things: -add some kind of the timestamp to the job. -don't redirect anything to the /dev/null . -set a $MAILTO notification to send output to the required team We are using Nagios for this and also cronwatch


2

You can do it with this: { crontab -l; echo "30 23 * * * /path_to/script/"; } | crontab -


1

Cron doesn't start with common environment variables that your user has, including $PATH. You have the full path in your cron, which is good, but you need to add it to your script as well. which lsof and which seoserver will give you the full path. Modify your script to use that instead of lsof and seoserver.


1

Almost all problems with scripts properly running from the commandline, but not from cron come from the setting of the PATH variable. According to man 5 crontab for Vixie cron: On the Debian GNU/Linux system, cron supports the pam_env module, and loads the environment specified by /etc/environment and /etc/secu‐ rity/pam_env.conf. It ...


1

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 or edit should be considered a ...


1

What you've written in your crontab entry doesn't match your stated need. The manpage (man 5 crontab) is reasonably clear on this: Step values can be used in conjunction with ranges. Following a range with "/" specifies skips of the number's value through the range. For example, "0-23/2" can be used in the hours field to specify command execution every ...


1

The solution that worked for me is I changed all of the paths within my two programs from relative paths ie: (./name_of_file.txt) to full paths (ie: /home/ed/directory/some_more_directory/name_of_file.txt) Was it just this, or a combination of the other things I did, I don't know - but changing the paths from relative to full path did it.


1

Your cron job is set to be executed at 20 hour 5 minutes (24 hour format). And the log you provide is from 9 a clock. So you should wait till 20h to see it in the log. And do not enter leading zeroes, this is not good practice, make your record like: 5 20 * * * root /data/CENTRAL_BACKUP/xxx.sh


1

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 `date +"%F %T"`" ...


1

find path-to-base-dir -maxdepth 1 \ -type d ! -name bunch-of-exceptions \ -mtime +7 -exec rm -rf {} \; -print You did not include path-to-base-dir in the bunch-of-exceptions. (You included . but that would only match if path-to-base-dir was exactly .) The only condition that the directory path-to-base-dir might fail if -mtime +7. If the ...


1

I recommend using at, not cron, because that way you won't have to remember to remove the crontab entry when the 24 hours are up. Just schedule 8 identical at jobs to run at the desired times (each 4 hours apart). In each job, you can, for example, use curl or wget, but of which can easily support writing the downloaded contents wherever you want it.


1

Your script does cat wlr3queue.txt etc.... where are those files to be found? When you're trying by hand you're running ./wlr3queuetransaction.sh but from cron you're calling with the complete pathname. Cron will run your command from the crontab's owner's home directory; presumably the files you're accessing in your script aren't in that home directory. ...


1

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 no longer created by the openvpn process ...


1

Cron jobs can be run as root or another specified user. If that user does not have the permission to write to the .sql file the job will fail. If the file exist and it has write permission for the user running the job the file will be written. if the file does not exist and the user does not have permission to create files in target directory, the job will ...


1

I think your cron configuration is correct. I'm not completely familiar with the python webbrower.open() function, but I assume that you are expecting the python script to open your page in a visible browser window. I think what's happening here is that when you call the script from the command line it works because it's running within your graphical ...


1

If you need default system wide PATHs and other ENV variables (which defined in /etc/profile.d), just put the following: * * * * * . /etc/profile; your cmd



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