Hot answers tagged

3

What you need is a lock file and check for this lock file. If it is there end the script otherwise start it. An example command would be shlock. DESCRIPTION Shlock tries to create a lock file named name and write the process ID pid into it. If the file already exists, shlock will read the process ID from the file and test to see if the ...


3

Thats a perfect output, to explain it a bit I'll take it step by step: SpiRegistry daemon is running with well-known name - org.ally.atspi.Registry This one seems to be a system daemon, not really sure what he does. Starting User manager for UID 1000 This is the UID of your users group. UID 108 This is the syslogs group UID. CRON [3076]: pam_unix (cron:...


3

Make sure your script has set the execute flag when executing it directly or use bash as interpreter with the script as input. To use bash as interpreter change the line to 0 4 24-31 * 4 bash /home/backupscript.sh To set the execute flag for the script use: chmod +x /home/backupscript.sh


2

The other answer is great! But it requires root cron. If you want to hibernate from non-sudo cron, there are 2 options: 1. Using polkit Make a file containing the following: [Enable hibernate to be run via cron] Identity=unix-user:* Action=org.freedesktop.login1.hibernate;org.freedesktop.login1.hibernate-multiple-sessions ResultAny=yes named ...


2

First, this command will find and delete all files older than 7 days in any subdirectory in /home whose name starts with securityuser: find '/home/securityuser*' -mtime +6 -type f -delete You need -mtime +6 and not +7 because -mtime counts 24h periods. As explained in the -atime section of man find (-mtime works in the same way): -atime n ...


2

A bash script must start with a shebang, to let the launching process know it's a script that should be run in the bash shell. So the first line of your script should be #!/bin/bash. This is a good convention to get into, it is how bash scripts should be written. Your script currently works when you run bash /home/backupscript.sh because you're already ...


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

as per i my knowledge: try find command like this: find ./dirc/* -mtime +6 -type f -delete ./dirc/* : is your directory (Path) -mtime +6 : modified more than 6 days ago (therefore, at least 7 days ago) -type f : only files -delete : no surprise. Remove it to test before like rm


1

I created my-script on Windows, so the shebang was correct, but had a Windows line ending. This will cause a cron script to fail. Recreating the script on Ubuntu (and chmodding it etc) fixed the problem.


1

Looked like you previously had some quotation issues. Using ascii quotes won't work well with code, use the standard coding quote (") instead. Ascii quotes come from word processors like libreoffice or abiword; don't use those programs for coding. Use something like gedit or leafpad. Also, are you putting this in /etc/crontab? If so, you need to add a user ...


1

This is happening because it needs root privileges. The solution is to add the hibernate command using sudo crontab -e instead of crontab -e. polkit is necessary for power management as an unprivileged user. If you are in a local systemd-logind user session and no other session is active, the following commands will work without root privileges. If ...


1

to execute a bash script via cron i would use 30 14 * * * /bin/bash /home/flicker/open-web.sh >/dev/null 2>&1 To call a web page/URL via cron & curl 30 14 * * * /usr/bin/curl http://funkyname.com/blub.html >/dev/null 2>&1 Update: After realizing you want to open an actual browser and NOT just calling a script - i guess i ...


1

I did some investigation on this, if your did "sudo crontab -e" with rtcwake inside the table without sudo, you will get the error message: /home/leo/autojob: line 4: rtcwake: command not found it seems that although "sudo crontab -e" is executed under root account, it cannot find the right command path. There are some other post says you shall put PATH ...


1

I had the same problem with mysqldump 5.7.13 in a script launched by crontab. You can set the .mylogin.cnf file location using the MYSQL_TEST_LOGIN_FILE environment variable before calling the mysqldump command : export MYSQL_TEST_LOGIN_FILE=/root/.mylogin.cnf mysqldump --login-path=mysqldump [...]


1

In 16.04, if you have this error in syslog (CRON) error (can't fork) try: systemctl status cron.service In the result: Tasks: num_task (limit: 512) If num_task is close to the limit use: systemctl set-property cron.service TasksMax=new_max Replace new_max with a suitable value.



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